xollef
Technical User
- Apr 23, 2002
- 30
Hi
I have a form with buttons on it. When i press a button it opens another form. I used the buttonwizard and created the button and there I linked the ID field that shows up on both forms so when pressing the button the other form opens with same record nr as in the "main form".
The problem is when the "main form" gets a new nr (autonumber). The buttons won't open the other forms anymore because they don't have the corresponding nr. So how do I solve this. When pressing the button and the nr isn't in the other form yet it should add it there and open.
I am using Access 2002 and I am not good at VB.
The code the wizard made is:
Private Sub Command106_Click()
On Error GoTo Err_Command106_Click
Dim stDocName As String
Dim stLinkCriteria As String
stDocName = "Viikkonaytteet_lammonjohtavuus"
stLinkCriteria = "[ID]=" & Me![ID]
DoCmd.OpenForm stDocName, , , stLinkCriteria
Exit_Command106_Click:
Exit Sub
Err_Command106_Click:
MsgBox Err.Description
Resume Exit_Command106_Click
End Sub
I have a form with buttons on it. When i press a button it opens another form. I used the buttonwizard and created the button and there I linked the ID field that shows up on both forms so when pressing the button the other form opens with same record nr as in the "main form".
The problem is when the "main form" gets a new nr (autonumber). The buttons won't open the other forms anymore because they don't have the corresponding nr. So how do I solve this. When pressing the button and the nr isn't in the other form yet it should add it there and open.
I am using Access 2002 and I am not good at VB.
The code the wizard made is:
Private Sub Command106_Click()
On Error GoTo Err_Command106_Click
Dim stDocName As String
Dim stLinkCriteria As String
stDocName = "Viikkonaytteet_lammonjohtavuus"
stLinkCriteria = "[ID]=" & Me![ID]
DoCmd.OpenForm stDocName, , , stLinkCriteria
Exit_Command106_Click:
Exit Sub
Err_Command106_Click:
MsgBox Err.Description
Resume Exit_Command106_Click
End Sub