I have created a find first function, that will ask the user to input a series of criteria to search by, use this criteria to find the specific record and then use the final user input to update part of the record.
I have written thusly:
Private Sub cmdFrame_Click()
Dim fra, occ, car, cat, dat, ms1, ms2, ms3, ms4, ms5, title, default As String
Dim db As DATABASE
Dim rst As Recordset
On Error GoTo err_frame
ms1 = "Please enter the Occurrence Number."
ms2 = "Please enter the Card Number."
ms3 = "Please enter the Merchant Cat Code."
ms4 = "Please enter the date of use."
ms5 = "Enter the Frame Ref Number to input."
title = "Frame Reference Number Update"
default = "1"
occ = InputBox(ms1, title, default)
car = InputBox(ms2, title, default)
cat = InputBox(ms3, title, default)
dat = InputBox(ms4, title, default)
fra = InputBox(ms5, title, default)
Set db = CurrentDb
Set rst = db.OpenRecordset("tblCardUse", dbOpenDynaset)
With rst
.FindFirst (!Occurrence = occ And !CardNo = car And !MerCat = cat And !Date = dat)
If .NoMatch Then
MsgBox "No Existing Record, please check what you have entered."
Else
.edit
!FrameRef = fra
.Update
MsgBox "The Frame Reference Number has been updated."
End If
.Close
End With
Exit_frame:
Exit Sub
err_frame:
MsgBox Err.Number
MsgBox Err.Description
Resume Exit_frame
Me.Refresh
The response i get is that there is no matching records, although i no there is and am entering the information correctly.
Can some see where i've gone wrong.
Cheers,
Adam
I have written thusly:
Private Sub cmdFrame_Click()
Dim fra, occ, car, cat, dat, ms1, ms2, ms3, ms4, ms5, title, default As String
Dim db As DATABASE
Dim rst As Recordset
On Error GoTo err_frame
ms1 = "Please enter the Occurrence Number."
ms2 = "Please enter the Card Number."
ms3 = "Please enter the Merchant Cat Code."
ms4 = "Please enter the date of use."
ms5 = "Enter the Frame Ref Number to input."
title = "Frame Reference Number Update"
default = "1"
occ = InputBox(ms1, title, default)
car = InputBox(ms2, title, default)
cat = InputBox(ms3, title, default)
dat = InputBox(ms4, title, default)
fra = InputBox(ms5, title, default)
Set db = CurrentDb
Set rst = db.OpenRecordset("tblCardUse", dbOpenDynaset)
With rst
.FindFirst (!Occurrence = occ And !CardNo = car And !MerCat = cat And !Date = dat)
If .NoMatch Then
MsgBox "No Existing Record, please check what you have entered."
Else
.edit
!FrameRef = fra
.Update
MsgBox "The Frame Reference Number has been updated."
End If
.Close
End With
Exit_frame:
Exit Sub
err_frame:
MsgBox Err.Number
MsgBox Err.Description
Resume Exit_frame
Me.Refresh
The response i get is that there is no matching records, although i no there is and am entering the information correctly.
Can some see where i've gone wrong.
Cheers,
Adam