Findfirst type mismatch error

M

mossmanrick

So I'm stumped

I have two fields that are able to have duplicates in them but
combined will not so I need to do my search criteria to include both
of them

Private Sub Command3_Click()

Dim MyRst As DAO.Recordset
Dim InputString As String
Dim acn2 As String

InputString = find
acn2 = accountnumber2
Set MyRst = Me.RecordsetClone
MyRst.FindFirst "[InvNum] = " & (InputString) And "[AccountNumber] = "
& Me![accountnumber2]
If MyRst.NoMatch Then
MsgBox ("No Data with this ID found")
Else
Me.Bookmark = MyRst.Bookmark
End If
MyRst.Close
Set MyRst = Nothing

Both AccountNumber and accountnumber2 are comboboxes sourcing the same
info from another table and have identical properties

This part works
MyRst.FindFirst "[InvNum] = " & (InputString)

So I know the type mismatch is occuring here
And "[AccountNumber] = " & Me![accountnumber2]

I've also let acn2 = accountnumber2 to turn it to a string and subbed
it in, to no avail.

I'm using Access 2000

Any suggestions
 
K

Krzysztof Pozorek [MVP]

(...)
This part works
MyRst.FindFirst "[InvNum] = " & (InputString)

If InputString is number..., then OK.
So I know the type mismatch is occuring here
And "[AccountNumber] = " & Me![accountnumber2]

Correct code is following:

MyRst.FindFirst "(InvNum = " & InputString & _
") And (AccountNumber= " & Me!accountnumber2 & ")"
 
A

AMELIE

So I'm stumped

I have two fields that are able to have duplicates in them but
combined will not so I need to do my search criteria to include both
of them

Private Sub Command3_Click()

Dim MyRst As DAO.Recordset
Dim InputString As String
Dim acn2 As String

InputString = find
acn2 = accountnumber2
Set MyRst = Me.RecordsetClone
MyRst.FindFirst "[InvNum] = " & (InputString) And "[AccountNumber] = "
& Me![accountnumber2]
If MyRst.NoMatch Then
MsgBox ("No Data with this ID found")
Else
Me.Bookmark = MyRst.Bookmark
End If
MyRst.Close
Set MyRst = Nothing

Both AccountNumber and accountnumber2 are comboboxes sourcing the same
info from another table and have identical properties

This part works
MyRst.FindFirst "[InvNum] = " & (InputString)

So I know the type mismatch is occuring here
And "[AccountNumber] = " & Me![accountnumber2]

I've also let acn2 = accountnumber2 to turn it to a string and subbed
it in, to no avail.

I'm using Access 2000

Any suggestions
 

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

Top