Results 1 to 3 of 3

Thread: Open data base

  1. #1
    Join Date
    Jul 2009

    Question Unanswered: Open data base

    I have the follow code on a form with three unbound fields but when I try to save I get
    The database has been placed in a state by user 'Admin' on machine 'hp' that prevents it from bring opened or locked.

    What am I doing wrong I copied most of this code from a sample mdb
    I have not written much code before. Just learning.

    Private Sub Command6_Click()
    Dim err As Integer
    Dim cnn1 As ADODB.Connection
    Dim rstflights As ADODB.Recordset
    Dim strCnn As String

    'Check that all fields are filled in
    If bid.Text = "" Then
    err = err + 1
    MsgBox "Please fill in the Bat ID!" & err
    End If

    'if no errors insert data
    If err < 1 Then
    ' Open a connection.
    Set cnn1 = New ADODB.Connection
    mydb = "c:\accessdev\rclog bob.mdb"
    strCnn = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & mydb
    cnn1.Open strCnn

    ' Open flights table.
    Set rstflights = New ADODB.Recordset
    rstflights.CursorType = adOpenKeyset
    rstflights.LockType = adLockOptimistic
    rstflights.Open "flights", cnn1, , , adCmdTable

    'get the new record data
    rstflights!id = ibid
    ' need code for planes and battery

    ' Show the newly added data.
    MsgBox "New flights: " & rstflights!Name & " has been successfully added"

    'close connections

    MsgBox "An Error has occurred, please check and try again"
    End If

    End Sub

    Private Sub Command7_Click()
    bid = ""
    End Sub

  2. #2
    Join Date
    Jul 2009


    I got it working seems I have to close access sometimes to get access not sure why but I have it adding now. Not sure why field name [ibattery id] works but not [flights.ibattery id] don't work. How does it know which table if I have the save field name in two tables. I don't right now for descriptions names I use sfdescription where s is string and f is the first letter of the tables name.

  3. #3
    Join Date
    Oct 2004
    Melbourne, Australia

    Access syntax

    The period (.) divides an object from one of its properties. You should use the exclamation point (!) to separate the flight object from its child object battery id (as in fact you appear to have done elswhere in the script).

Posting Permissions

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