dkmoreland
Registered User.
- Local time
- Today, 14:42
- Joined
- Dec 6, 2017
- Messages
- 129
I am trying to use a form to find a record and open a second form to allow editing that record. But, I also want to load the other records in the table so the users can scroll through them. Here's my setup:
I have two unbound controls, Job number and NCR Number on the first form. The data source for both forms is the same - [Non Conformance].
The user should be able to enter the Job number OR the NCR number, click Continue, then the second form should open to the correct record.
This is the code I have in the On Click property for the Continue button. Right now I have it set to only look for the NCR number - I can add an if statement to look for the job number once I get the first search working:
I'm getting a "Sub or function not defined error". I suspect it is because this is the first time I have tried to used a recordset and FindFirst and I am doing it wrong. Would someone mind pointing out my error(s), please?
One more thing - I know that the field name listed above [NCR#] should not have a special character in it. I inherited this database and cannot rename it at this point. I only mention this because invariably, someone feels led to tell me this is a bad practice.
Thanks in Advance,
D
I have two unbound controls, Job number and NCR Number on the first form. The data source for both forms is the same - [Non Conformance].
The user should be able to enter the Job number OR the NCR number, click Continue, then the second form should open to the correct record.
This is the code I have in the On Click property for the Continue button. Right now I have it set to only look for the NCR number - I can add an if statement to look for the job number once I get the first search working:
Code:
Private Sub CmdNCRContinue_Click()
Set db = CurrentDb
Dim rs As Recordset
Set rs = dbOpenRecordSet("Non Conformance", dbOpenDynaset)
Dim strNCR As Long
lngNCR = Me.TextNCR
rs.FindFirst (lngNCR)
If rs.NoMatch Then
MsgBox "No records found"
Else
DoCmd.OpenForm "Resolve Non Conformance Form", , , "[NCR#] = " & lngNCR
End If
End Sub
I'm getting a "Sub or function not defined error". I suspect it is because this is the first time I have tried to used a recordset and FindFirst and I am doing it wrong. Would someone mind pointing out my error(s), please?
One more thing - I know that the field name listed above [NCR#] should not have a special character in it. I inherited this database and cannot rename it at this point. I only mention this because invariably, someone feels led to tell me this is a bad practice.

Thanks in Advance,
D