Results 1 to 7 of 7

Thread: how to add data into access database?

  1. #1

    Thread Starter
    _______ HeSaidJoe's Avatar
    Join Date
    Jun 1999
    Location
    Canada
    Posts
    3,946

    <?>

    What is the name of your data control cause that is what the line is all about..it's saying get ready for a new entry. I think it means you don't have a datacontrol called data1.

    Wayne
    "A myth is not the succession of individual images,
    but an integerated meaningful entity,
    reflecting a distinct aspect of the real world."

    ___ Adolf Jensen

  2. #2
    New Member
    Join Date
    Aug 2000
    Location
    Glasgow
    Posts
    5
    HeSaidJoe,

    I have checked the properties for my data control it's called data1.

    Thanks

    Tahir
    Visual Basic 6.0 Enterprise Edition

    saqi_the_angel

  3. #3

    Thread Starter
    _______ HeSaidJoe's Avatar
    Join Date
    Jun 1999
    Location
    Canada
    Posts
    3,946

    <?>

    Give me 10 0r 20...I'll post a bit of code here and you can
    do the adjusting ot suit your project. Make sure your data1 control is pointing to the correct MDB and that the recordsource is set.

    "A myth is not the succession of individual images,
    but an integerated meaningful entity,
    reflecting a distinct aspect of the real world."

    ___ Adolf Jensen

  4. #4

    Thread Starter
    _______ HeSaidJoe's Avatar
    Join Date
    Jun 1999
    Location
    Canada
    Posts
    3,946

    <?> ..this is as good as it gets..

    Code:
    Option Explicit
    
    Public cDBName As String
    Public cTblName As String
    
     
    Public Sub OpenDB()
    
       Dim db As Database, rs As Recordset
       Dim AppPath$
                
            If Right(App.Path, 1) <> "\" Then _
                AppPath = App.Path & "\" _
            Else AppPath = App.Path
            
                cDBName = AppPath & "YourDatabaseName.mdb"
            
                cTblName = "YourTable"
          Set db = Workspaces(0).OpenDatabase(cDBName)
          Set rs = db.OpenRecordset(cTblName)
                Data1.DatabaseName = cDBName
                Data1.RecordSource = cTblName
             
                Data1.Refresh
    
         End Sub
    
    Private Sub Command1_Click()
        Data1.Recordset.AddNew
        Data1.Recordset!YourField = Text1.Text
        Data1.Recordset.Update
        Data1.Refresh
        Command1.Enabled = False
        
        
    End Sub
    
    Private Sub Form_Activate()
    '
          Call OpenDB
    '
          
          Form1.Data1.Recordset.movefirst
    
    'I edited this line
    'this line I use to test reading your file (not needed)     
         'Text1.Text = Data1.Recordset!YourField
    End Sub

    [Edited by HeSaidJoe on 08-29-2000 at 05:15 PM]
    "A myth is not the succession of individual images,
    but an integerated meaningful entity,
    reflecting a distinct aspect of the real world."

    ___ Adolf Jensen

  5. #5
    New Member
    Join Date
    Aug 2000
    Location
    Glasgow
    Posts
    5

    Wink

    HeSaidJoe,

    I think we are getting there. Now I have got problem with integer field

    Data1.Recordset!pubid = Text4.Text
    pubid is long integer what should i use it instead of test.

    I get run time error.

    Data type conversion error

    What should I use use instead of text.

    Thanks

    Tahir
    Visual Basic 6.0 Enterprise Edition

    saqi_the_angel

  6. #6

    Thread Starter
    _______ HeSaidJoe's Avatar
    Join Date
    Jun 1999
    Location
    Canada
    Posts
    3,946

    <?>

    try = Cint(text4.text)
    or Val(text4.text)
    "A myth is not the succession of individual images,
    but an integerated meaningful entity,
    reflecting a distinct aspect of the real world."

    ___ Adolf Jensen

  7. #7

    Thread Starter
    _______ HeSaidJoe's Avatar
    Join Date
    Jun 1999
    Location
    Canada
    Posts
    3,946

    <?>

    sorry...that should be CLng(text4.text)

    trying to do too many things at once here.
    "A myth is not the succession of individual images,
    but an integerated meaningful entity,
    reflecting a distinct aspect of the real world."

    ___ Adolf Jensen

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width