S
stockton12
I have a command button on a form that will open another form. Attached is
the code:
Private Sub cmdLog_Click()
On Error GoTo Err_cmdLog_Click
Dim stDocName As String
Dim stLinkCriteria As String
stDocName = "frmLog"
stLinkCriteria = "[Customer ID]=" & Me![txtCustomerID]
DoCmd.OpenForm stDocName, , , stLinkCriteria
Exit_cmdLog_Click:
Exit Sub
Err_cmdLog_Click:
MsgBox Err.Description
Resume Exit_cmdLog_Click
End Sub
Now, in the frmLog, If a record exist for that customer, I want a new record
to display with the customer number from the frmMain to display. If the
customer does not have a record in this table, simply display a new record
with the customer number from the frmMain.
On the frmLog, I have this code:
Private Sub Form_Load()
Me![txtCustomer] = Forms!frmmain!txtCustomerID
DoCmd.RunCommand acCmdRecordsGoToNew
Me![txtCustomer] = Forms!frmmain!txtCustomerID
End Sub
This works OK, if a record exists for the customer, however if the record
does not exist, I get an error stating that the NewRecordAdd cannot occur.
Any Ideas?
the code:
Private Sub cmdLog_Click()
On Error GoTo Err_cmdLog_Click
Dim stDocName As String
Dim stLinkCriteria As String
stDocName = "frmLog"
stLinkCriteria = "[Customer ID]=" & Me![txtCustomerID]
DoCmd.OpenForm stDocName, , , stLinkCriteria
Exit_cmdLog_Click:
Exit Sub
Err_cmdLog_Click:
MsgBox Err.Description
Resume Exit_cmdLog_Click
End Sub
Now, in the frmLog, If a record exist for that customer, I want a new record
to display with the customer number from the frmMain to display. If the
customer does not have a record in this table, simply display a new record
with the customer number from the frmMain.
On the frmLog, I have this code:
Private Sub Form_Load()
Me![txtCustomer] = Forms!frmmain!txtCustomerID
DoCmd.RunCommand acCmdRecordsGoToNew
Me![txtCustomer] = Forms!frmmain!txtCustomerID
End Sub
This works OK, if a record exists for the customer, however if the record
does not exist, I get an error stating that the NewRecordAdd cannot occur.
Any Ideas?