Hi I have coded one of my forms in a database to search a query via a unique process number entered into a box within the form.
If the process number in the form matches one in the query,the relevant query record is displayed. If no match is found a message box telling the user that no match can be found is displayed.
This seems to work for 75% of the time, but on occasions is displaying records that don't match the number in the form. I have posted my VBA code below.
I am fairly competent with excel visual basic but am still learning in access so please bear with me!
Private Sub Command75_Click()
On Error GoTo REASON_Err
DoCmd.OpenQuery "RESULTS", acViewNormal, acReadOnly
DoCmd.FindRecord Forms![OGW DATA ENTRY]!PROCESS_ID1, acEntire, True, , True, acCurrent, True
DoCmd.RunCommand acCmdFilterBySelection
DoCmd.MoveSize 25, 25, 17500, 1500
MsgBox "PROCESS ID DOES NOT MATCH A WASTE RECORD", vbOKOnly
Call Command78_Click
REASON_Exit:
Exit Sub
REASON_Err:
MsgBox Error$
Resume REASON_Exit
End Sub
Private Sub Command78_Click()
DoCmd.Close acQuery, "RESULTS", acSaveNo
End Sub
If the process number in the form matches one in the query,the relevant query record is displayed. If no match is found a message box telling the user that no match can be found is displayed.
This seems to work for 75% of the time, but on occasions is displaying records that don't match the number in the form. I have posted my VBA code below.
I am fairly competent with excel visual basic but am still learning in access so please bear with me!
Private Sub Command75_Click()
On Error GoTo REASON_Err
DoCmd.OpenQuery "RESULTS", acViewNormal, acReadOnly
DoCmd.FindRecord Forms![OGW DATA ENTRY]!PROCESS_ID1, acEntire, True, , True, acCurrent, True
DoCmd.RunCommand acCmdFilterBySelection
DoCmd.MoveSize 25, 25, 17500, 1500
MsgBox "PROCESS ID DOES NOT MATCH A WASTE RECORD", vbOKOnly
Call Command78_Click
REASON_Exit:
Exit Sub
REASON_Err:
MsgBox Error$
Resume REASON_Exit
End Sub
Private Sub Command78_Click()
DoCmd.Close acQuery, "RESULTS", acSaveNo
End Sub