Results 1 to 4 of 4
  1. #1
    mejia.j88 is offline Competent Performer
    Windows 7 64bit Access 2007
    Join Date
    Nov 2011
    Location
    california
    Posts
    228

    Question trouble with one line of code

    hi guys,



    i have the following code and it is giving me an error with this line

    ElseIf IsNull(Frame92) & IsNull(Frame107) Then

    the full code is listed below.

    Code:
    Private Function CheckBeforeSaving() As Boolean
        If IsNull(Me.txtPart_Number) Then
            MsgBox "Please select a Part Number from the list."
            CheckBeforeSaving = False
            Me!txtPart_Number.SetFocus
        ElseIf IsNull(txtEvaporation_Lot) Then
            MsgBox "Please enter Evaporation Lot."
            CheckBeforeSaving = False
            Me!txtEvaporation_Lot.SetFocus
        ElseIf IsNull(txtDiffusion_Lot) Then
            MsgBox "Please enter Diffusion Lot."
            CheckBeforeSaving = False
            Me!txtDiffusion_Lot.SetFocus
        ElseIf IsNull(txtWork_Order) Then
            MsgBox "Please enter Work Order."
            CheckBeforeSaving = False
            Me!txtWork_Order.SetFocus
        ElseIf IsNull(txtOperator) Then
            MsgBox "Please select your operator ID."
            CheckBeforeSaving = False
            Me!txtOperator.SetFocus
        ElseIf IsNull(Frame92) & IsNull(Frame107) Then
            MsgBox "Please select a Saw or Dicer."
            CheckBeforeSaving = False
        Else
            CheckBeforeSaving = True
        End If
            
    End Function
    the error says: error type data mismatch,
    I'm not sure if the syntax is correct with the & in between the two IfNull.

    This might help: there are a total of 8 check boxes, with values 1-8 that go to one, Saw_no. They are separated into two frames because depending on the part, the operator will choose a saw from either frame 92 or frame 107.
    So it is either of those two, but both cannot remain empty when saving the record. i.e. Saw_no must always contain a value.

    any help regarding this issue would be a marvelous help.

    Thanks all!

  2. #2
    pbaldy's Avatar
    pbaldy is offline Who is John Galt?
    Windows XP Access 2007
    Join Date
    Feb 2010
    Location
    Nevada, USA
    Posts
    22,518
    & is a concatenation operator. Try

    ElseIf IsNull(Frame92) And IsNull(Frame107) Then
    Paul (wino moderator)
    MS Access MVP 2007-2019
    www.BaldyWeb.com

  3. #3
    mejia.j88 is offline Competent Performer
    Windows 7 64bit Access 2007
    Join Date
    Nov 2011
    Location
    california
    Posts
    228
    thanks so much pbaldy, that worked perfect.
    one more question, can you briefly explain the difference between &, and, and +?
    i have read somewhere that VB can take + to mean "and, or &" unless its a value, in which case it will perform mathematics..

  4. #4
    pbaldy's Avatar
    pbaldy is offline Who is John Galt?
    Windows XP Access 2007
    Join Date
    Feb 2010
    Location
    Nevada, USA
    Posts
    22,518
    Generally, & is a concatenation operator, + is a math operator, And is a logical operator. Sometimes Access will make the correct assumption when you switch them, but not always, and I wouldn't rely on it.
    Paul (wino moderator)
    MS Access MVP 2007-2019
    www.BaldyWeb.com

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

Similar Threads

  1. trouble starting code
    By mejia.j88 in forum Programming
    Replies: 32
    Last Post: 12-15-2011, 11:57 AM
  2. How to execute Line of Code
    By jo15765 in forum Programming
    Replies: 4
    Last Post: 06-22-2011, 05:37 PM
  3. How to do line by line compare of VB code?
    By Buakaw in forum Access
    Replies: 2
    Last Post: 02-14-2011, 11:46 PM
  4. Anything wrong with this one line of code?
    By alsoto in forum Reports
    Replies: 3
    Last Post: 07-01-2009, 09:23 AM
  5. Code Trouble?
    By briancb2004 in forum Access
    Replies: 0
    Last Post: 10-08-2008, 04:47 PM

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