Hi Guys, please could someone help? I have a form on which I have put a combo box and button on to find records, it has the following code and works well..
Private Sub cmdGotoRecord_Click()
On Error GoTo Err_cmdGotoRecord_Click
Dim strReport As Integer
Dim tmp As Integer
strReport = Me.cboSelectRptNo
'abort if number not selected
If Len(Trim(strReport)) = 0 Then
MsgBox "Report number Not Selected"
End If
'get current ReportNo
tmp = Me.ReportNo
Me.ReportNo.Enabled = True
Me.ReportNo.SetFocus
DoCmd.FindRecord strReport
' move to some other control to
' be able to be able to set
' ReportNo Enabled to false
Me.cmdGotoRecord.SetFocus
Me.ReportNo.Enabled = False
'check if the report no. was found and
If (tmp = Me.ReportNo) And (Me.ReportNo <> strReport) Then
MsgBox "Report number " & strReport & " Not found"
End If
Exit_cmdGotoRecord_Click:
Exit Sub
Err_cmdGotoRecord_Click:
MsgBox Err.Description
Resume Exit_cmdGotoRecord_Click
End Sub
The problem is, I have a switchboard on which I have put a similar combo and button to find a record and to open the form and display the record, for this I altered the original code to..
Private Sub cmdGotoActRecord_Click()
On Error GoTo Err_cmdGotoActRecord_Click
Dim strReport As Integer
Dim tmp As Integer
strReport = Me.cboSelectAccAct
'abort if number not selected
If Len(Trim(strReport)) = 0 Then
MsgBox "Report number Not Selected"
End If
'get current ReportNo
tmp = Forms!frmInspSht!ReportNo
Forms!frmInspSht!ReportNo.Enabled = True
Forms!frmInspSht!ReportNo.SetFocus
DoCmd.FindRecord strReport
' move to some other control to
' be able to be able to set
' ReportNo Enabled to false
Forms!frmInspSht!cmdGotoActRecord.SetFocus
Forms!frmInspSht!ReportNo.Enabled = False
'check if the report no. was found and
If (tmp = Forms!frmInspSht!ReportNo) And (Forms!frmInspSht!ReportNo <> strReport) Then
MsgBox "Report number " & strReport & " Not found"
End If
Exit_cmdGotoActRecord_Click:
Exit Sub
Err_cmdGotoActRecord_Click:
MsgBox Err.Description
Resume Exit_cmdGotoActRecord_Click
End Sub
When I select the record in the combo and click the button I get the following messege
Microsoft cannot find the referenced file 'frmInspSht'
What have i done wrong??
Thanks Andy