Results 1 to 8 of 8
  1. #1
    opopanax666 is offline Novice
    Windows XP Access 2007
    Join Date
    Aug 2010
    Posts
    27

    Newbie Dlookup problem


    Hi everyone,

    Complete Access newbie trying to get to grips with this stuff...

    • I have a table ("tblProductie") which contains 2 colums ("Pcode" & "Locatie");
    • I have a form ("frmLocatie"), containing a combo box ("cboCode") which lists all "Pcodes", and a text box ("txtLocatie");
    • I have following code:
    Code:
    Option Compare Database
     
    Private Sub cboCode_AfterUpdate()
    txtLocatie = DLookup([locatie], "tblproductie", "[pcode]=" & cboCode)
    End Sub
    but when I use the combo to choose a "Pcode", so that "txtLocatie" shows the corresponding value of "Locatie", I get an "error 2465 can't find field | (vertical line)"...

    Anybody know what I did wrong? Thank you.
    Last edited by opopanax666; 08-13-2010 at 05:48 AM.

  2. #2
    SoftwareMatters is offline Access VBA Developers
    Windows XP Access 2003
    Join Date
    Mar 2009
    Location
    Dorset
    Posts
    274
    Have you checked the data in the table?

  3. #3
    opopanax666 is offline Novice
    Windows XP Access 2007
    Join Date
    Aug 2010
    Posts
    27
    Quote Originally Posted by SoftwareMatters View Post
    Have you checked the data in the table?
    Everything ("Pcode" & "Locatie") is in text format, if that's what you mean...

  4. #4
    SoftwareMatters is offline Access VBA Developers
    Windows XP Access 2003
    Join Date
    Mar 2009
    Location
    Dorset
    Posts
    274
    No, I meant the actual data in the table i.e. the records.

    If PCode is text then you need to add some quotes like this:
    txtLocatie = DLookup([locatie], "tblproductie", "[pcode]='" & cboCode & "'")

  5. #5
    opopanax666 is offline Novice
    Windows XP Access 2007
    Join Date
    Aug 2010
    Posts
    27
    Nope, still gives the same error, not finding "|"...
    I can see, however, why your solution might have solved be the problem, but the "Pcodes" are in fact formed by a letter followed by 6 numbers, so there can be no mistake as to whether it's a string or not.
    The location codes, however, are stored as text, but are in fact 6 numbers, so maybe the problem lies there, but I don't know where to insert single quotes in the expression. I tried:
    Code:
    Option Compare Database
    Private Sub cboCode_AfterUpdate()
    txtLocatie = DLookup("'" & [locatie] & "'", "tblproductie", "[pcode]='" & cboCode & "'")
    End Sub
    but no go

    I'm a bit stumped, I thought this was one of the easiest things to do in Access, but obviously not

  6. #6
    maximus's Avatar
    maximus is offline Expert
    Windows 7 Access 2010 (version 14.0)
    Join Date
    Aug 2009
    Location
    India
    Posts
    931
    if pcode is a number Field.

    Dlookup("[Locatie]","tblproductie","[pcode]=" & Me.cbocode)

    if pcode is a text Field:
    Dlookup("[Locatie]","tblproductie","[pcode]='" & Me.cbocode & "'")

    Depending on the type of the Field use one of the following.

  7. #7
    maximus's Avatar
    maximus is offline Expert
    Windows 7 Access 2010 (version 14.0)
    Join Date
    Aug 2009
    Location
    India
    Posts
    931
    is your problem solved

  8. #8
    opopanax666 is offline Novice
    Windows XP Access 2007
    Join Date
    Aug 2010
    Posts
    27
    Quote Originally Posted by maximus View Post
    is your problem solved
    Well, there's no error message anymore, but nothing is shown in the textbox "txtLocatie", and when I insert a msgbox in the code, it returns a null error for "txtLocatie"...

    Never mind. By searching the web I was reminded of Northwind. This example db has been used for years to explain stuff.
    So what I'm gonna do is have a deeper look at NW, and maybe I'll get the hang of the "logic" behind Access a bit more...

    So for the moment I'll mark this post as "Solved", and thank you both very much for trying to help. Cheers!

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

Similar Threads

  1. Need help with dlookup.
    By Keith in forum Database Design
    Replies: 8
    Last Post: 05-24-2010, 06:28 PM
  2. dlookup function problem
    By bdaniel in forum Programming
    Replies: 3
    Last Post: 04-26-2010, 05:55 AM
  3. Newbie format number problem
    By mrbob2 in forum Queries
    Replies: 9
    Last Post: 01-18-2010, 07:18 AM
  4. Dlookup problem
    By CalifDan in forum Reports
    Replies: 4
    Last Post: 12-09-2009, 06:09 AM
  5. I have Problem in processing Dlookup Function
    By Katada in forum Programming
    Replies: 2
    Last Post: 04-23-2006, 12:07 AM

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