Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations TouchToneTommy on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Type Mismatch - Please help

Status
Not open for further replies.

Billybonga

IS-IT--Management
Jun 22, 2002
72
GB
I'm writing an application that uses allows me to receive data from a PiccoLink wireless barcode scanner.

I'm have difficulty searching and displaying data from a table. What I want to do is, on the hand held scanner there is a Supplier field. If the user does not enter a supplier field then it will display a list of all suppliers from the database from which they can select.

The system works in two halves, the PiccoLink form and then the datafrom processing.

Here is the code I am using:

Private Sub DataFromDelEntry(ByVal id As Long) ' Delivery Entry Data Processing

Dim retval As Boolean
Dim date_id As String
Dim del_id As String
Dim supplier As Long
Dim counter As Integer

If PLServer1.IsData(id, BACK_BUT) Then
SendMainMenu (id)
Exit Sub
End If


date_id = Date
del_id = PLServer1.GetData(id, DEL_REF_POS) 'Get delivery Id from data sent by scanner
supplier = Val(PLServer1.GetData(id, DEL_SUPP_POS)) 'Set the supplier input data
If supplier = 0 Then ' if no data for supplier is inputted then
'get db record of hand terminal
searchstr = "Name = '" & supplier & "'" 'create a search string from data table searching for supplier 'Name'
Data5.Recordset.FindFirst searchstr

PLServer1.ClearForm (id) 'Clear the scanner form
retval = PLServer1.Text(id, 0, "Select Supplier") ' Display form - Select Supplier
retval = PLServer1.Button(id, BACK_BUT, Chr(164) + Chr(165)) ' Display back button
Data5.Recordset.MoveFirst ' cycle data table
Do While Data5.Recordset.EOF = False
If supplier <> Data5.Recordset!Name Then
counter = counter + 1
retval = PLServer1.Button(id, (counter * 20), Str(Data5.Recordset!Name))
End If
Data5.Recordset.MoveNext
If (counter >= 10) Then Exit Do

Loop
retval = PLServer1.Send(id, supplier)


End If

End Sub

When run, it errors saying Runtime Error 13 - Type Mismatch and then highlights line :

retval = PLServer1.Button(id, (counter * 20), Str(Data5.Recordset!Name))


Can anyone see where I'm going wrong?

Thanks for the help
 
P.S. - The Piccolink Form side of things is fine, this is the data-processing side where I'm having the problems
 
Str works with numeric like entries. Otherwise you can get type mismatch
 
The Str function takes a numeric value as its parameter, and it looks as if you are sending a character/text field to it (Data5.Recordset!Name). This is what is causing the error.



I used to rock and roll every night and party every day. Then it was every other day. Now I'm lucky if I can find 30 minutes a week in which to get funky. - Homer Simpson
 
Is there another way I can search? - the suppliers names are not numeric.

Thanks for your help
 
retval is dimmed as Boolean - what does the PLServer1.Button(id, (counter * 20), Str(Data5.Recordset!Name)) function return?

In VB the Str function returns a Variant (String) representation of a number.

________________________________________________________________
If you want to get the best response to a question, please check out FAQ222-2244 first.
'If we're supposed to work in Hex, why have we only got A fingers?'
Essex Steam UK for steam enthusiasts
 
Cheers vladk and everyone - I removed Str and it works fine.

Thanks a million for the quick responces - Problem is now solved (fingers crossed )
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top