I have 2 forms, "Staff" and "Security" (without the ""'s). The Staff form has the following fields:
staff_ID
staff_name
staff_number
staff_DOB
priority
The Security form contains the following fields:
staff_ID
staff_pass
priority
The staff_ID fields in both forms are linked by a one-to-one relationship.
I have a command button (Command22) in the Staff form which, when pressed, opens the security form to the corresponding staff_ID value (for example, if I navigate to the record in the Staff form where staff_ID = 6 and press the Command22 button, the Security form is opened and the record in the Security form where staff_ID = 6 is displayed). Below is the code for the On Click event of the Command22 button:
However, when I create a new record in the Staff form and press Command22, a "Syntax error (missing operation) in query expression '[staff_ID]='" error comes up. I think this is because the database cannot find a corresponding staff_ID value in the Security form. What needs to be done so that, when a new record is created in the Staff form and the Command22 button is pressed, the Security form is opened to a new record?
Thanks in advance,
extrym
staff_ID
staff_name
staff_number
staff_DOB
priority
The Security form contains the following fields:
staff_ID
staff_pass
priority
The staff_ID fields in both forms are linked by a one-to-one relationship.
I have a command button (Command22) in the Staff form which, when pressed, opens the security form to the corresponding staff_ID value (for example, if I navigate to the record in the Staff form where staff_ID = 6 and press the Command22 button, the Security form is opened and the record in the Security form where staff_ID = 6 is displayed). Below is the code for the On Click event of the Command22 button:
Code:
Private Sub Command22_Click()
On Error GoTo Command22_Click_Err
DoCmd.OpenForm "Security", acNormal, "", "[staff_ID]=" & staff_ID, , acNormal
Command22_Click_Exit:
Exit Sub
Command22_Click_Err:
MsgBox Error$
Resume Command22_Click_Exit
End Sub
Thanks in advance,
extrym
Comment