Results 1 to 3 of 3
  1. #1
    5 Star Lounger
    Join Date
    Jan 2001
    Location
    austin, Texas, USA
    Posts
    1,029
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Recordset Not Updateable (Access 2K, Win2K Pro)

    It's happening again... I can't recall what I did last time to fix this, either.

    My problem is simply this: I want to put a button on a form to display another form where I can enter specific information to a separate table. The column RequestNumber is meant to link Table/Form A to Table/Form B. I can't seem to get this right. How do I make it so, when table/form B is opened, the RequestNumber from table/form B automatically gets written to table/form B if it doesn't already exist? and if it does, just display the info on that record. That is, use automation to create a new record if RecordNumber doesn't already exist or display only the data on table/form B if it does exist. This entails writing RecordNumber from table/form A into table/form B once.

    Thanks very much in advance for any help on this!

  2. #2
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts

    Re: Recordset Not Updateable (Access 2K, Win2K Pro)

    Let's say FormA is based on TableA and FormB is based on TableB. I will assume that RequestNumber is a number field; I will note the changes needed if it is a text field later on.
    Put a command button cmdOpenB on FormA. The On Click event procedure for the button looks like this:

    Private Sub cmdOpenB_Click()
    If DCount("*", "TableB", "RequestNumber = " & Me.RequestNumber) = 0 Then
    ' No matching record
    DoCmd.OpenForm FormName:="FormB", DataMode:=acFormAdd
    Forms!FormB!RequestNumber = Me.RequestNumber
    Else
    ' Go to existing record
    DoCmd.OpenForm FormName:="FormB", WhereCondition:="RequestNumber = " & Me.RequestNumber
    End If
    End Sub

    Note: if RequestNumber is a text field, change both occurrences of the condition "RequestNumber = " & Me.RequestNumber to

    "RequestNumber = " & Chr(34) & Me.RequestNumber & Chr(34)

  3. #3
    5 Star Lounger
    Join Date
    Jan 2001
    Location
    austin, Texas, USA
    Posts
    1,029
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Recordset Not Updateable (Access 2K, Win2K Pro)

    thanks for the quick reply. I was delving into an ADO-based solution but this looks cleaner. DLookup! I keep forgetting.

    and the other thing is the code

    Forms!FormB!RequestNumber = Me.RequestNumber

    that's the basic nut of the solution to passing var values...

    thanks! now I can move on with this thing.

Posting Permissions

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