Results 1 to 15 of 15
  1. #1
    vkumar is offline Advanced Beginner
    Windows 7 64bit Access 2010 64bit
    Join Date
    Jan 2012
    Posts
    30

    Smile Need Help with run time error 3075

    I am getting run time error 3075 syntax error missing operator in query expression '[Job Number] = '

    Here is my code:

    Private Sub Job_Number_BeforeUpdate(Cancel As Integer)
    If IsNull(DLookup("[Job Number]", "[Job]", "[Job Number]= " & Me.[Job Number] & " ")) Then
    MsgBox "Job Number doesn't exist Enter a job number that already exist."
    Cancel = True
    End If
    End Sub

    Please help! Thank you

  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,640
    Given the error, it appears that the form control is Null. Should it have an underscore? Also, why not use a combo box so the user can't enter a bad number?
    Paul (wino moderator)
    MS Access MVP 2007-2019
    www.BaldyWeb.com

  3. #3
    amrut is offline Expert
    Windows 7 64bit Access 2010 32bit
    Join Date
    Jun 2012
    Location
    India
    Posts
    616
    I think the space at the end shown in red may be throwing an error. Remove that part and try.
    If IsNull(DLookup("[Job Number]", "[Job]", "[Job Number]= " & Me.[Job Number] & " ")) Then

  4. #4
    vkumar is offline Advanced Beginner
    Windows 7 64bit Access 2010 64bit
    Join Date
    Jan 2012
    Posts
    30

    Run time error

    Thank you for your reply.
    When I enter correct Job number it is working fine, only If I delete the job number and clear the form it gives that error. There are thousands of job number, the customer didn't want the combo box.
    Quote Originally Posted by pbaldy View Post
    Given the error, it appears that the form control is Null. Should it have an underscore? Also, why not use a combo box so the user can't enter a bad number?

  5. #5
    vkumar is offline Advanced Beginner
    Windows 7 64bit Access 2010 64bit
    Join Date
    Jan 2012
    Posts
    30
    Thank you for your reply. I tried after removing the space, it didn't work.

    Quote Originally Posted by amrut View Post
    I think the space at the end shown in red may be throwing an error. Remove that part and try.
    If IsNull(DLookup("[Job Number]", "[Job]", "[Job Number]= " & Me.[Job Number] & " ")) Then

  6. #6
    Missinglinq's Avatar
    Missinglinq is offline VIP
    Windows 7 64bit Access 2007
    Join Date
    May 2012
    Location
    Richmond (Virginia, not North Yorkshire!)
    Posts
    3,018
    Two things:

    At the Table-level, is [Job Number] defined as a Number Datatype? I ask the syntax you're using is only correct for a Number, not for Text. A Field made up entirely of digits can, of course, be defined as Text.

    When doing this type of a check, the DCount() is usually used, rather than DLookup():

    Code:
    If DCount("[Job Number]", "[Job]", "[Job Number]= " & Me.[Job Number]) > 0 Then

    Linq ;0)>

  7. #7
    pbaldy's Avatar
    pbaldy is offline Who is John Galt?
    Windows XP Access 2007
    Join Date
    Feb 2010
    Location
    Nevada, USA
    Posts
    22,640
    Quote Originally Posted by vkumar View Post
    Thank you for your reply.
    When I enter correct Job number it is working fine, only If I delete the job number and clear the form it gives that error. There are thousands of job number, the customer didn't want the combo box.
    If it's only failing when you delete a job number, test the job number before running the DLookup to make sure it has a value.
    Paul (wino moderator)
    MS Access MVP 2007-2019
    www.BaldyWeb.com

  8. #8
    vkumar is offline Advanced Beginner
    Windows 7 64bit Access 2010 64bit
    Join Date
    Jan 2012
    Posts
    30

    run time error 3075

    Job number is a number field. Thank you for your reply.

    Quote Originally Posted by Missinglinq View Post
    Two things:

    At the Table-level, is [Job Number] defined as a Number Datatype? I ask the syntax you're using is only correct for a Number, not for Text. A Field made up entirely of digits can, of course, be defined as Text.

    When doing this type of a check, the DCount() is usually used, rather than DLookup():

    Code:
    If DCount("[Job Number]", "[Job]", "[Job Number]= " & Me.[Job Number]) > 0 Then

    Linq ;0)>

  9. #9
    vkumar is offline Advanced Beginner
    Windows 7 64bit Access 2010 64bit
    Join Date
    Jan 2012
    Posts
    30
    If I enter a correct job number no problem. But if I don't have the correct job number, I can't clear the form or I can't close the form until I enter a correct job number. It gives the run time error. Once if enter the correct job number, I can clear or close the form. When the user makes a mistake and don't have the correct job number then the user is stuck there and can't close the form and can't come out. It is not a good design of a DB. I really need to fix this glitch.

    Quote Originally Posted by pbaldy View Post
    If it's only failing when you delete a job number, test the job number before running the DLookup to make sure it has a value.

  10. #10
    pbaldy's Avatar
    pbaldy is offline Who is John Galt?
    Windows XP Access 2007
    Join Date
    Feb 2010
    Location
    Nevada, USA
    Posts
    22,640
    Like I said, first test to make sure it has something in it:

    If Len(Me.[Job Number] & vbNullString) > 0 Then
    Paul (wino moderator)
    MS Access MVP 2007-2019
    www.BaldyWeb.com

  11. #11
    vkumar is offline Advanced Beginner
    Windows 7 64bit Access 2010 64bit
    Join Date
    Jan 2012
    Posts
    30

    Run time error

    Sorry for being so dumb. I am not able to incorportae two if statements (I tried And it didn't work). How to do it with the code I have. Job number is a number field. Thank you.


    Quote Originally Posted by pbaldy View Post
    Like I said, first test to make sure it has something in it:

    If Len(Me.[Job Number] & vbNullString) > 0 Then

  12. #12
    pbaldy's Avatar
    pbaldy is offline Who is John Galt?
    Windows XP Access 2007
    Join Date
    Feb 2010
    Location
    Nevada, USA
    Posts
    22,640
    Put that line first and another

    End If

    last.
    Paul (wino moderator)
    MS Access MVP 2007-2019
    www.BaldyWeb.com

  13. #13
    vkumar is offline Advanced Beginner
    Windows 7 64bit Access 2010 64bit
    Join Date
    Jan 2012
    Posts
    30

    Run time error

    This is what I have now. It still gives me the run time error. Unless the user enters the correct Job number, the user can't clear the form or close the form.

    Private Sub Job_Number_BeforeUpdate(Cancel As Integer)
    If Len(Me.[Job Number] & vbNullString) > 0 Then
    If IsNull(DLookup("[Job Number]", "[Job]", "[Job Number]= " & Me.[Job Number] & " ")) Then
    MsgBox "Job Number doesn't exist Enter a job number that already exist."
    Cancel = True
    End If
    End If

    Quote Originally Posted by pbaldy View Post
    Put that line first and another

    End If

    last.

  14. #14
    pbaldy's Avatar
    pbaldy is offline Who is John Galt?
    Windows XP Access 2007
    Join Date
    Feb 2010
    Location
    Nevada, USA
    Posts
    22,640
    It should only be running the DLookup if there's a value in the job number. Can you post the db here?
    Paul (wino moderator)
    MS Access MVP 2007-2019
    www.BaldyWeb.com

  15. #15
    vkumar is offline Advanced Beginner
    Windows 7 64bit Access 2010 64bit
    Join Date
    Jan 2012
    Posts
    30

    Run Time error

    Myfile is too big to attach it here, I have stored it in free online storage place and you can use the following link to download (Judy IMS.accdb) it.


    http://www.sendspace.com/file/nlbsgj

    Thank you again for helping me.

    P.S. In the Enter Payment form if you don't enter the correct Job Number, you can't clear the form or close it. If enter the correct Job number you can clear the form or close it after clearing the form.

    Quote Originally Posted by pbaldy View Post
    It should only be running the DLookup if there's a value in the job number. Can you post the db here?

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

Similar Threads

  1. Replies: 9
    Last Post: 06-08-2012, 07:11 PM
  2. Run Time Error '3075'
    By ertweety in forum Programming
    Replies: 2
    Last Post: 06-03-2012, 04:26 PM
  3. Replies: 6
    Last Post: 05-30-2012, 12:32 PM
  4. Replies: 5
    Last Post: 03-27-2012, 01:40 PM
  5. Run Time Error 3075 in Access 2007
    By jblank65 in forum Programming
    Replies: 6
    Last Post: 01-25-2011, 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