Results 1 to 4 of 4
  1. #1
    jctaylor is offline Novice
    Windows 10 Access 2016
    Join Date
    Jul 2017
    Posts
    16

    OpenArgs data type mismatch in criteria expression

    I am trying to pass an invoice number(a string) to another form.



    Private Sub Form_Open(Cancel As Integer)
    If VarType(Me.OpenArgs) <> vbString Then
    MsgBox ("Not a string")
    Else
    MsgBox Me.OpenArgs
    End If
    Me.RecordSource = " SELECT tickt.* from tickt where tickt.inv_no = " & Me.OpenArgs
    End Sub

    I get a Data Type mismatch in criteria expression. I checked to make sure it was a string and I am trying to select a string value. What I am missing?

  2. #2
    andy49's Avatar
    andy49 is offline VIP
    Windows 10 Access 2010 64bit
    Join Date
    Nov 2016
    Location
    London
    Posts
    1,051
    Have you tried cstr(me.openargs) to change it to a string?

  3. #3
    aytee111 is offline Competent At Times
    Windows 10 Access 2013 64bit
    Join Date
    Nov 2011
    Location
    Nomad
    Posts
    3,936
    Strings must be enclosed in quotes - = '" & Me.OpenArgs & "'"

    It may be simpler to open the form with a WHERE criteria, no code will be needed.

  4. #4
    jctaylor is offline Novice
    Windows 10 Access 2016
    Join Date
    Jul 2017
    Posts
    16
    That worked. Thanks a lot!!

Please reply to this thread with any new information or opinions.

Similar Threads

  1. Data Type Mismatch on Criteria Expression
    By Mikejsinclair in forum Programming
    Replies: 3
    Last Post: 10-19-2016, 03:37 AM
  2. Data type mismatch in criteria expression
    By hazeleyre23 in forum General Chat
    Replies: 2
    Last Post: 03-24-2016, 05:33 AM
  3. Data type mismatch in criteria expression
    By khughes46 in forum Queries
    Replies: 12
    Last Post: 05-01-2014, 07:34 AM
  4. Data type mismatch in criteria expression
    By bobt_1234 in forum Queries
    Replies: 3
    Last Post: 02-13-2012, 03:37 PM
  5. Data type mismatch in criteria expression
    By Douglasrac in forum Forms
    Replies: 3
    Last Post: 11-23-2010, 10:46 AM

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Other Forums: Microsoft Office Forums