J
Jen
I am trying to link to forms. I have a button on the main form
(frmCompanies) that needs to open another form when a button is clicked. The
new form that opens is frmScheduledActivities. When it open it needs to check
to see if there is an existing record (scheduled activity) for the company
and if there is no scheduled activity be set to add a new record.
When the button is clicked on the main company form (on the on click event)
this code runs:
Private Sub cmdCallBack_Click()
On Error GoTo Err_cmdCallBack_Click
Dim stDocName As String
Dim stLinkCriteria As String
DoCmd.OpenForm "frmScheduleCallBack", , , , , , Me.CompanyID
Then on the other form that opens on the load event I have this code that
runs:
This checks to see if there is a related record and display it if it finds
one. If there is no related record it is ready to insert a new record.
I keep getting a datatype mismatch error on line 6 (below). The companyID in
the company table is an autonumber. I know that I can't compare a long
integer to a string and get a match but how do I handle this problem??
1Private Sub Form_Load()
2Dim strCompanyID As String
3 If Not IsNull(Me.OpenArgs) Then
4 strCompanyID = Me.OpenArgs
5 With Me.RecordsetClone
6 .FindFirst "[CompanyID] = '" & strCompanyID & "'"
7 If .NoMatch Then
8 DoCmd.GoToRecord , , acNewRec
9 Me.txtCompanyID = strCompanyID
10 Else
11 Me.Bookmark = .Bookmark
12 End If
13 End With
14 End If
End Sub
(frmCompanies) that needs to open another form when a button is clicked. The
new form that opens is frmScheduledActivities. When it open it needs to check
to see if there is an existing record (scheduled activity) for the company
and if there is no scheduled activity be set to add a new record.
When the button is clicked on the main company form (on the on click event)
this code runs:
Private Sub cmdCallBack_Click()
On Error GoTo Err_cmdCallBack_Click
Dim stDocName As String
Dim stLinkCriteria As String
DoCmd.OpenForm "frmScheduleCallBack", , , , , , Me.CompanyID
Then on the other form that opens on the load event I have this code that
runs:
This checks to see if there is a related record and display it if it finds
one. If there is no related record it is ready to insert a new record.
I keep getting a datatype mismatch error on line 6 (below). The companyID in
the company table is an autonumber. I know that I can't compare a long
integer to a string and get a match but how do I handle this problem??
1Private Sub Form_Load()
2Dim strCompanyID As String
3 If Not IsNull(Me.OpenArgs) Then
4 strCompanyID = Me.OpenArgs
5 With Me.RecordsetClone
6 .FindFirst "[CompanyID] = '" & strCompanyID & "'"
7 If .NoMatch Then
8 DoCmd.GoToRecord , , acNewRec
9 Me.txtCompanyID = strCompanyID
10 Else
11 Me.Bookmark = .Bookmark
12 End If
13 End With
14 End If
End Sub