Run time error 13 - type mismatch

Please support our Visual Basic 4 / 5 / 6 advertiser: Programming Forums - DaniWeb Sister Site
Reply

Join Date: Mar 2008
Posts: 63
Reputation: Cosa is an unknown quantity at this point 
Solved Threads: 0
Cosa Cosa is offline Offline
Junior Poster in Training

Run time error 13 - type mismatch

 
0
  #1
Jun 15th, 2009
Hi,
Im new to VB. Im just trying to do a simple if statement that will open a specific form based on user input. The database requires me to scan in a barcode from a card. I then want to check if that barcode number is already in the database. to do this i have tried the following code.

  1. Private Sub Barcode_AfterUpdate()
  2. Dim curDatabase As Object
  3. Dim tblStore_Barcode As Object
  4. Dim tblPersonal As Object
  5.  
  6.  
  7. Set curDatabase = CurrentDb
  8. Set tblStore_Barcode = curDatabase.TableDefs("Store_Barcode")
  9. Set tblPersonal = curDatabase.TableDefs("Personal")
  10.  
  11.  
  12. If [Store_Barcode]![Barcode] = [Personal]![Barcode] Then
  13. DoCmd.OpenForm (Personal_2)
  14. Else
  15. DoCmd.OpenForm (Personal)
  16. End If
  17. End Sub

I recieve the Run time error 13 - type mismatch
Visual Basic 4 / 5 / 6 Syntax (Toggle Plain Text)
  1. If [Store_Barcode]![Barcode] = [Personal]![Barcode] Then
This is the line that is highlighted. Any ideas why it is doing this?
Reply With Quote Quick reply to this message  
Join Date: May 2007
Posts: 21
Reputation: Cruize_Invades is an unknown quantity at this point 
Solved Threads: 1
Cruize_Invades's Avatar
Cruize_Invades Cruize_Invades is offline Offline
Newbie Poster

Re: Run time error 13 - type mismatch

 
0
  #2
Jun 15th, 2009
Please check the data type of the fields 'Barcode' in both table, the Personal and the Store_Barcode. The data type of the two must be the same, example the Barcode in Personal is in Integer data type and the other is in "Text/Char" data type, then it would really return an Error.
Reply With Quote Quick reply to this message  
Join Date: Mar 2008
Posts: 63
Reputation: Cosa is an unknown quantity at this point 
Solved Threads: 0
Cosa Cosa is offline Offline
Junior Poster in Training

Re: Run time error 13 - type mismatch

 
0
  #3
Jun 15th, 2009
The datatype is the same for both. I made sure of that before i attempted writing the code, and i have since checked it several times to be sure.

I believe the problem is with the actual syntax. However i dont know why it is doing this.
Reply With Quote Quick reply to this message  
Join Date: Mar 2008
Posts: 63
Reputation: Cosa is an unknown quantity at this point 
Solved Threads: 0
Cosa Cosa is offline Offline
Junior Poster in Training

Re: Run time error 13 - type mismatch

 
0
  #4
Jun 15th, 2009
Any ideas guys?
Reply With Quote Quick reply to this message  
Join Date: Mar 2009
Posts: 828
Reputation: vb5prgrmr will become famous soon enough vb5prgrmr will become famous soon enough 
Solved Threads: 150
vb5prgrmr vb5prgrmr is offline Offline
Practically a Posting Shark

Re: Run time error 13 - type mismatch

 
0
  #5
Jun 16th, 2009
Unless the two tables are exact (TableDefs) then they... Is this VBA?
If anyone has helped you solve your problem, please mark your thread as solved.

Thanks
Reply With Quote Quick reply to this message  
Join Date: Jul 2007
Posts: 300
Reputation: jireh is an unknown quantity at this point 
Solved Threads: 42
jireh's Avatar
jireh jireh is offline Offline
Posting Whiz

Re: Run time error 13 - type mismatch

 
0
  #6
Jun 17th, 2009
try to remove the bracket "[]"

Visual Basic 4 / 5 / 6 Syntax (Toggle Plain Text)
  1. If [Store_Barcode]![Barcode] = [Personal]![Barcode] Then

or try to look the value if it is DBNull. dbnull is not a string type in which if you will try to use it in comparison of strings it would throw an exception error...
Last edited by jireh; Jun 17th, 2009 at 11:12 am.
Reply With Quote Quick reply to this message  
Reply

This thread is more than three months old.
Perhaps start a new thread instead?
Message:



Similar Threads
Other Threads in the Visual Basic 4 / 5 / 6 Forum
Thread Tools Search this Thread



About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC