Type mismatch

M

Mabeline

I have received help previously for this problem but I am now having other
problems that I can't work out. I want to be able to enter a tag number into
a field on a form that will retrieve the record from the database table whose
key matches the inputted tag number and display that record on the same form.
The Tag number field field in the table is unique no duplicates allowed so
there is only one record.

I am using Access 2000/2002 and have a form that has an unbound field that I
have called FindRecord and have populated the rest of the form with the
fields I require data to be inserted into from the database table.

As instructed I set up an event procedure as an afterupdate call and wrote
the following code in the event procedure:

Private Sub FindRecord_AfterUpdate()
Dim rs As Object
Set rs = Me.RecordsetClone
rs.FindFirst "[Tag Number] = " & Str(Me![FindRecord])
If Not rs.NoMatch Then Me.Bookmark = rs.Bookmark
End Sub

I get an error type mismatch '13' on the rs.Findfirst "[Tag Number] etc line.

The unbound field on the form is a text box and the table field tag number
is text up to 15 characters. The data I have entered into the unbound field
is B12346. I don't know why this is not bringing the data back into the
fields and why it is not working. I need some more expert help.

Thanks in advance
Mabeline.
 
R

Rob Parker

I have received help previously for this problem but I am now having other
problems that I can't work out. I want to be able to enter a tag number into
a field on a form that will retrieve the record from the database table whose
key matches the inputted tag number and display that record on the same form.
The Tag number field field in the table is unique no duplicates allowed so
there is only one record.

I am using Access 2000/2002 and have a form that has an unbound field that I
have called FindRecord and have populated the rest of the form with the
fields I require data to be inserted into from the database table.

As instructed I set up an event procedure as an afterupdate call and wrote
the following code in the event procedure:

Private Sub FindRecord_AfterUpdate()
Dim rs As Object
Hi Mabeline,

Since you are using a text field, you need to delimit the variable
with text delimiters. If FindRecord does not contain any single-quote
(apostrophe) characters, you can use the single-quote character as the
delimiter:
rs.FindFirst "[Tag Number] = '" & Str(Me![FindRecord]) & "'"
Expanded for clarity, that's:
rs.FindFirst "[Tag Number] = ' " & Str(Me![FindRecord]) & " ' "

If FindRecord may contain a single-quote character, use a pair of
double-quote characters:
rs.FindFirst "[Tag Number] = """ & Str(Me![FindRecord]) & """"
Again,expanded for clarity, that's:
rs.FindFirst "[Tag Number] = " " " & Str(Me![FindRecord]) & " " " "

HTH,

Rob

Set rs = Me.RecordsetClone
rs.FindFirst "[Tag Number] = " & Str(Me![FindRecord])
If Not rs.NoMatch Then Me.Bookmark = rs.Bookmark
End Sub

I get an error type mismatch '13' on the rs.Findfirst "[Tag Number] etc line.

The unbound field on the form is a text box and the table field tag number
is text up to 15 characters. The data I have entered into the unbound field
is B12346. I don't know why this is not bringing the data back into the
fields and why it is not working. I need some more expert help.

Thanks in advance
Mabeline.
 
U

UpRider

Rob, that might not work in this particular case. The Type mismatch happens
because the argument for the Str function must be numeric. In this case it
is not. Your solution will work if Mabeline removes the Str() surrounding
the Me![FindRecord].

UpRider

Rob Parker said:
I have received help previously for this problem but I am now having
other
problems that I can't work out. I want to be able to enter a tag number
into
a field on a form that will retrieve the record from the database table
whose
key matches the inputted tag number and display that record on the same
form.
The Tag number field field in the table is unique no duplicates allowed
so
there is only one record.

I am using Access 2000/2002 and have a form that has an unbound field
that I
have called FindRecord and have populated the rest of the form with the
fields I require data to be inserted into from the database table.

As instructed I set up an event procedure as an afterupdate call and
wrote
the following code in the event procedure:

Private Sub FindRecord_AfterUpdate()
Dim rs As Object
Hi Mabeline,

Since you are using a text field, you need to delimit the variable
with text delimiters. If FindRecord does not contain any single-quote
(apostrophe) characters, you can use the single-quote character as the
delimiter:
rs.FindFirst "[Tag Number] = '" & Str(Me![FindRecord]) & "'"
Expanded for clarity, that's:
rs.FindFirst "[Tag Number] = ' " & Str(Me![FindRecord]) & " ' "

If FindRecord may contain a single-quote character, use a pair of
double-quote characters:
rs.FindFirst "[Tag Number] = """ & Str(Me![FindRecord]) & """"
Again,expanded for clarity, that's:
rs.FindFirst "[Tag Number] = " " " & Str(Me![FindRecord]) & " " " "

HTH,

Rob

Set rs = Me.RecordsetClone
rs.FindFirst "[Tag Number] = " & Str(Me![FindRecord])
If Not rs.NoMatch Then Me.Bookmark = rs.Bookmark
End Sub

I get an error type mismatch '13' on the rs.Findfirst "[Tag Number] etc
line.

The unbound field on the form is a text box and the table field tag
number
is text up to 15 characters. The data I have entered into the unbound
field
is B12346. I don't know why this is not bringing the data back into the
fields and why it is not working. I need some more expert help.

Thanks in advance
Mabeline.
 
M

Mabeline

Thanks Rob this worked fine.

Could you help with when I open the form how do I start with blank fields
rather then the first record details that are automatically displayed from
the table.

Thanks again
Mabeline.

Rob Parker said:
I have received help previously for this problem but I am now having other
problems that I can't work out. I want to be able to enter a tag number into
a field on a form that will retrieve the record from the database table whose
key matches the inputted tag number and display that record on the same form.
The Tag number field field in the table is unique no duplicates allowed so
there is only one record.

I am using Access 2000/2002 and have a form that has an unbound field that I
have called FindRecord and have populated the rest of the form with the
fields I require data to be inserted into from the database table.

As instructed I set up an event procedure as an afterupdate call and wrote
the following code in the event procedure:

Private Sub FindRecord_AfterUpdate()
Dim rs As Object
Hi Mabeline,

Since you are using a text field, you need to delimit the variable
with text delimiters. If FindRecord does not contain any single-quote
(apostrophe) characters, you can use the single-quote character as the
delimiter:
rs.FindFirst "[Tag Number] = '" & Str(Me![FindRecord]) & "'"
Expanded for clarity, that's:
rs.FindFirst "[Tag Number] = ' " & Str(Me![FindRecord]) & " ' "

If FindRecord may contain a single-quote character, use a pair of
double-quote characters:
rs.FindFirst "[Tag Number] = """ & Str(Me![FindRecord]) & """"
Again,expanded for clarity, that's:
rs.FindFirst "[Tag Number] = " " " & Str(Me![FindRecord]) & " " " "

HTH,

Rob

Set rs = Me.RecordsetClone
rs.FindFirst "[Tag Number] = " & Str(Me![FindRecord])
If Not rs.NoMatch Then Me.Bookmark = rs.Bookmark
End Sub

I get an error type mismatch '13' on the rs.Findfirst "[Tag Number] etc line.

The unbound field on the form is a text box and the table field tag number
is text up to 15 characters. The data I have entered into the unbound field
is B12346. I don't know why this is not bringing the data back into the
fields and why it is not working. I need some more expert help.

Thanks in advance
Mabeline.
 
M

Mabeline

Thanks UpRider this worked fine.

Could you help with when I open the form how do I start with blank fields
rather then the first record details that are automatically displayed from
the table.

Thanks again
Mabeline.


UpRider said:
Rob, that might not work in this particular case. The Type mismatch happens
because the argument for the Str function must be numeric. In this case it
is not. Your solution will work if Mabeline removes the Str() surrounding
the Me![FindRecord].

UpRider

Rob Parker said:
I have received help previously for this problem but I am now having
other
problems that I can't work out. I want to be able to enter a tag number
into
a field on a form that will retrieve the record from the database table
whose
key matches the inputted tag number and display that record on the same
form.
The Tag number field field in the table is unique no duplicates allowed
so
there is only one record.

I am using Access 2000/2002 and have a form that has an unbound field
that I
have called FindRecord and have populated the rest of the form with the
fields I require data to be inserted into from the database table.

As instructed I set up an event procedure as an afterupdate call and
wrote
the following code in the event procedure:

Private Sub FindRecord_AfterUpdate()
Dim rs As Object
Hi Mabeline,

Since you are using a text field, you need to delimit the variable
with text delimiters. If FindRecord does not contain any single-quote
(apostrophe) characters, you can use the single-quote character as the
delimiter:
rs.FindFirst "[Tag Number] = '" & Str(Me![FindRecord]) & "'"
Expanded for clarity, that's:
rs.FindFirst "[Tag Number] = ' " & Str(Me![FindRecord]) & " ' "

If FindRecord may contain a single-quote character, use a pair of
double-quote characters:
rs.FindFirst "[Tag Number] = """ & Str(Me![FindRecord]) & """"
Again,expanded for clarity, that's:
rs.FindFirst "[Tag Number] = " " " & Str(Me![FindRecord]) & " " " "

HTH,

Rob

Set rs = Me.RecordsetClone
rs.FindFirst "[Tag Number] = " & Str(Me![FindRecord])
If Not rs.NoMatch Then Me.Bookmark = rs.Bookmark
End Sub

I get an error type mismatch '13' on the rs.Findfirst "[Tag Number] etc
line.

The unbound field on the form is a text box and the table field tag
number
is text up to 15 characters. The data I have entered into the unbound
field
is B12346. I don't know why this is not bringing the data back into the
fields and why it is not working. I need some more expert help.

Thanks in advance
Mabeline.
 

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