Enter Parameter Values Problem

M

Mark R. Rutter

I have the following VB code associated with a form:

Private Sub Text23_AfterUpdate()
'Text23 allows for user input of a new Invoice Number

'Check that entered Invoice Number does not already exist
' in tblInvoice
Set MyRS = Me.RecordsetClone
' Build Criteria
Criteria = "[InvoiceNumber] ='" & Me.Text23 & "'"
' Perform the Search
MyRS.FindFirst Criteria
If Not MyRS.NoMatch = True Then 'Found existing match to Invoice Number
MsgBox "Invoice Number " & MyRS!InvoiceNumber & " already used with"
& vbCrLf & _
"Job Number " & MyRS!JobNumber & "."

Me.Text23 = "" 'Clear Text23 Text Box
Exit Sub 'Exit Sub
End If

'Entered Invoice Number is Unique,
'Add New tblInvoice Record with initial information
Set MyRS = Me.RecordsetClone
MyRS.AddNew 'Add a new record
MyRS!JobNumber = Me.txtJobNo 'Job Number
MyRS!InvoiceNumber = Me.Text23 'Invoice Number as entered in text box
MyRS!InvoiceDate = Date 'Set Invoice Date to Current Date
MyRS.Update 'Update tblInvoice
MyRS.Close

'Put focus on New Record in tblInvoice
Set MyRS = Me.RecordsetClone
' Build Criteria
Criteria = "[InvoiceNumber] ='" & Me.Text23 & "'"
' Perform the Search
MyRS.FindFirst Criteria
If Not MyRS.NoMatch = True Then
' Sync the form's record to the dynaset's record.
Me.Bookmark = MyRS.Bookmark
End If
InvoiceDate.Visible = True 'Show Invoice Date

MyRS.Close

'Set Initial Information in subform sfrmInvoiceItems
Form!sfrmInvoiceItems!JobNumber = Me.txtJobNo
Form!sfrmInvoiceItems!InvoiceNumber = Me.txtInvoiceNumber
Form!sfrmInvoiceItems!HoldCall = "Call"
End Sub

In Access 2003 this worked fine, but in Access 2007 I get a 'Enter Parameter
Value' message box. I think the issues are in the following line were I am
putting values into a new record:

MyRS!JobNumber = Me.txtJobNo 'Job Number
MyRS!InvoiceNumber = Me.Text23 'Invoice Number as entered in text box

What changed. I am also having this sort of problem elsewhere.

Thanks,
Mark
 
D

Douglas J. Steele

See whether it makes a difference using

MyRS!JobNumber = Me!txtJobNo 'Job Number
MyRS!InvoiceNumber = Me!Text23 'Invoice Number as entered in text
box
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Similar Threads


Top