Opening Forms

  • Thread starter Thread starter administrator
  • Start date Start date
A

administrator

In FRMabc I have a command to open FRMcde using the common
field "id", both tables "id" is a "no duplicates" field.
So that if I have ID=83 in FRMabc, FRMcde opens
with "id=83". However, it's opening up a new form
everytime. I would like it to open first with any data
already entered in FRMcde for ID=83, then if there hasn't
been any data already for ID=83, then a new form opens.
How would I write the IIf statement?
 
administrator said:
In FRMabc I have a command to open FRMcde using the common
field "id", both tables "id" is a "no duplicates" field.
So that if I have ID=83 in FRMabc, FRMcde opens
with "id=83". However, it's opening up a new form
everytime. I would like it to open first with any data
already entered in FRMcde for ID=83, then if there hasn't
been any data already for ID=83, then a new form opens.
How would I write the IIf statement?

What is your current command to open the form?
 
Use the OpenArgs property to pass the ID value.
Code the Command button:
DoCmd.OpenForm "FormName", , , , , , [ID]

Code the Load event of FRMcde to either filter or go to a new record:

Private Sub Form_Load()

If Not IsNull(OpenArgs) Then
If DCount("*", "YourTableName", "[ID] = " & Me.OpenArgs) > 0 Then
Me.Filter = "[ID] = " & Me.OpenArgs
Me.FilterOn = True
Else
DoCmd.RunCommand acCmdRecordsGoToNew
End If
End If

End Sub
 
Back
Top