Results 1 to 6 of 6

Thread: syntax error??

  1. #1
    Join Date
    May 2002
    Posts
    395

    Unanswered: syntax error??

    I'm trying the find the part number in the table that match to part number of the form.

    I got this error message:
    "MS Access can't find the field 'l' referred to your expression"

    Private Sub Report_Open(Cancel As Integer)
    Dim targetval As Integer
    Dim txttargetvalue As Integer


    If [Target Values]![Part Number] = Forms![Part Print]!Parts Then

    '[Target Values]![Part Number] is a field in the Target Values table
    'tblname, fieldname are correct

    targetval = [Target Values]!target
    'Debug.Print targetval

    End If

    End Sub

    But when I used DLookup function I didn't get the error message
    targetval = DLookup("Target", "[Target Values]", "[Target Values].[Part Number] = Forms![Part Print]!Parts
    (I can't use DLookup func because I ran into some other issues.)

    Can you tell me what it could be wrong?
    Help!
    Thanks!

  2. #2
    Join Date
    Mar 2002
    Location
    Sacramento, CA
    Posts
    120
    Just a guess, but make sure all of your ! (exclamations) are actually ! (exclamations)

    Check for a l(small Ls) also.

    Also check that your brackets [ ] are brackets not a small L.

    Michael

  3. #3
    Join Date
    May 2002
    Posts
    395
    Originally posted by mrabrams
    Just a guess, but make sure all of your ! (exclamations) are actually ! (exclamations)

    Check for a l(small Ls) also.

    Also check that your brackets [ ] are brackets not a small L.

    Michael
    Hello,
    Unfortunately, All checked out.

    What does the field 'l' in
    "MS Access can't find the field 'l' referred to your expression" means?

    Should I use ! or . to reference a table?

    Any suggestions of how I can find the value in a field of a table that match to value in a form?

    Thanks!

  4. #4
    Join Date
    Sep 2002
    Location
    Land of OZ
    Posts
    173
    Originally posted by alicejwz
    Hello,
    Unfortunately, All checked out.

    What does the field 'l' in
    "MS Access can't find the field 'l' referred to your expression" means?

    Should I use ! or . to reference a table?

    Any suggestions of how I can find the value in a field of a table that match to value in a form?

    Thanks!
    Is the code above copied from the database... and that is exactly what it looks line.

    Which line is it stopping on.

    Try compiling the module and seeing which line it freaks out on.

    Mona
    Mona
    ________________________________
    Life is too short to be sane or sensible. Weird people rule and normal people suck

  5. #5
    Join Date
    May 2002
    Posts
    395

    match the value of a field in table against a field in form

    Originally posted by mona
    Is the code above copied from the database... and that is exactly what it looks line.

    Which line is it stopping on.

    Try compiling the module and seeing which line it freaks out on.

    Mona
    Hi,

    What I¡¯m trying to do is populate the two fields in a report base on a table"Target Values" while the recordsource for the same report is based on another table.

    I want to use the If/then statement to match the value in a field in table ¡°Target Values¡± ([Target Values]![Part Number] )
    to the value in form(Forms![Part Print]!Parts)
    and return two values from table ¡°Target Values¡±.
    For some reason It just won¡¯t recognize the [Target Values]![Part Number] in the If statement

    If [Target Values]![Part Number] = Forms![Part Print]!Parts Then

    '[Target Values]![Part Number] is a field in the Target Values table
    'tblname, fieldname are correct

    targetval = [Target Values]!Target
    Cavval = [Target Values]!Cavities
    'Debug.Print targetval

    End If

    Could I check the value of a field in table against a field in form?



    Thanks for your reply.
    I appreciate your help,

  6. #6
    Join Date
    Mar 2003
    Location
    Navarro, CA
    Posts
    5
    Hi! I had the same error recently so I saved a link to this post, but I was looking for something else at the time... Did you ever find the answer?

    I'm new at Access, so I don't know what the problem is, but as an old mainframe programmer I have suggestions for narrowing down which part of your code has the problem if Access is being too vague to help.

    First, comment out the code you suspect as having the problem to make sure the rest of it runs without errors. Then uncomment a line at a time. This will quickly tell you exactly which line has the problem, in case the debugger is lying - occasionally it flags the wrong line.

    Second, assign your table and form values to variables and then do the "If" statement (or function or whatever) with the variables. It may seem silly, but it can help you narrow down which half of your "If" statement has the problem. All these brackets and bangs and dots seem to confuse the compiler as much as they do me... or maybe it's just me. Once you know you have the punctuation right, try putting the tables and forms references back in the "If" instead of the variables.

    MargaretB

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •