Results 1 to 8 of 8
  1. #1
    burrina's Avatar
    burrina is offline VIP
    Windows 7 64bit Access 2010 64bit
    Join Date
    Oct 2012
    Location
    Freeport,Texas
    Posts
    1,383

    DLookup Code Not Working

    DLookUp("startingbalance","TBanks","bankid = " & [bankid])



    I am trying to use this to lookup the startingbalance from table TBanks and use as the default value on a textbox but I get no errors, just no data?
    bankid is the primary key and TBanks is the table and startingbalance is the field I want to lookup!

    The form where the textbox is located is named FReg and has its primary key as RegID

  2. #2
    Bob Fitz's Avatar
    Bob Fitz is offline Access Developer
    Windows XP Access 2003
    Join Date
    May 2011
    Location
    Essex UK
    Posts
    3,610
    I'm not sure but I think your problem is that the default is only used on a new record. But on a new record [bankid] has no value.
    If this helped, please click the star at the bottom left of this posting and add to my reputation . Many thanks.
    Bob Fitzpatrick

  3. #3
    burrina's Avatar
    burrina is offline VIP
    Windows 7 64bit Access 2010 64bit
    Join Date
    Oct 2012
    Location
    Freeport,Texas
    Posts
    1,383

    DLookup , Form, Not a New Record.

    Well, actually the form has many records.
    Attached Thumbnails Attached Thumbnails CheckRegister.jpg  

  4. #4
    Bob Fitz's Avatar
    Bob Fitz is offline Access Developer
    Windows XP Access 2003
    Join Date
    May 2011
    Location
    Essex UK
    Posts
    3,610
    If I'm right about the problem, it doesn't matter how many records you have. What matters is that the Default Value is only invoked with a new record, but in a new record [bankid] has no value.
    Perhaps you could use:
    = DLookUp("startingbalance","TBanks","bankid = " & [bankid])
    as the Record Source property of a textbox.
    If this helped, please click the star at the bottom left of this posting and add to my reputation . Many thanks.
    Bob Fitzpatrick

  5. #5
    burrina's Avatar
    burrina is offline VIP
    Windows 7 64bit Access 2010 64bit
    Join Date
    Oct 2012
    Location
    Freeport,Texas
    Posts
    1,383
    Hmm, tried that with no luck. And yes you were right, no value for bankid due to the unique way the form is. Have to figure something else out or the user has to enter it manualy! Not good.

  6. #6
    Bob Fitz's Avatar
    Bob Fitz is offline Access Developer
    Windows XP Access 2003
    Join Date
    May 2011
    Location
    Essex UK
    Posts
    3,610
    When and how does bankid get populated with a value.
    If this helped, please click the star at the bottom left of this posting and add to my reputation . Many thanks.
    Bob Fitzpatrick

  7. #7
    burrina's Avatar
    burrina is offline VIP
    Windows 7 64bit Access 2010 64bit
    Join Date
    Oct 2012
    Location
    Freeport,Texas
    Posts
    1,383

    copy bank info into chk register

    It gets populated via a popup form where you choose the bank. Also due to some unusual things with the form it also uses this code on the on open event.
    Me.Bank.DefaultValue = """" & Me.Bank.Value & """"



    Is there a way for me too copy over the values of the fields from the bank form to the check register form?
    The bank form has all of the info I need such as starting balance and I need to get this info onto my check register form. I attach a screenshot of the bank form. Can I do a insert or something else to automate this? Fields I need to copy over are;
    startingbalance
    startingchecknumber
    lastbankstatementbalance
    lastreconciliationdate
    Attached Thumbnails Attached Thumbnails bankform.jpg  
    Last edited by burrina; 02-20-2013 at 07:08 AM. Reason: different approach

  8. #8
    burrina's Avatar
    burrina is offline VIP
    Windows 7 64bit Access 2010 64bit
    Join Date
    Oct 2012
    Location
    Freeport,Texas
    Posts
    1,383
    I used my popup form to solve this and did a copy data over routine.

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

Similar Threads

  1. PLEASE HELP! Dlookup event not working....
    By emailloni in forum Forms
    Replies: 11
    Last Post: 01-10-2013, 12:43 PM
  2. Autofill using DLookup not working
    By BBonexx in forum Access
    Replies: 2
    Last Post: 01-08-2013, 09:18 PM
  3. DLookup isn't working
    By cec in forum Access
    Replies: 7
    Last Post: 12-28-2012, 12:21 PM
  4. order by dlookup not working
    By broof in forum Queries
    Replies: 3
    Last Post: 01-11-2011, 03:15 PM
  5. DLookup code not working
    By lukekelly in forum Programming
    Replies: 9
    Last Post: 06-15-2010, 06:08 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