Results 1 to 3 of 3
  1. #1
    BBonexx is offline Novice
    Windows 7 64bit Access 2010 64bit
    Join Date
    Dec 2012
    Posts
    4

    Autofill using DLookup not working

    Hello All,



    I am new to Access (using Access 2012) and All I am trying to achieve is to autofill the field [Frequency] from Table FullList based on the value of [Frequency] from Table Courses using a DLookup code used to update the FullList form. The code is not updating anything! It is frustrating! Frequency is a number (integer) and while Course is a text. Please help me on this issue, the figures of my Access database are below.


    Click image for larger version. 

Name:	FullList Table.png 
Views:	6 
Size:	28.4 KB 
ID:	10631Click image for larger version. 

Name:	Course Table.png 
Views:	6 
Size:	24.0 KB 
ID:	10632Click image for larger version. 

Name:	Form.png 
Views:	6 
Size:	20.2 KB 
ID:	10633Click image for larger version. 

Name:	AutoFill Code for form.jpg 
Views:	6 
Size:	56.3 KB 
ID:	10634

  2. #2
    NTC is offline VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    Nov 2009
    Posts
    2,392
    in your FullList form, if the Frequency field is bound (to the field in the FullList table) then DLookup isn't the way to go. You could have an unbound field that does the look up with its record source being:
    =DLookup("Frequency","Courses","Courses = " & Forms!FullList.Courses) - - this syntax is not correct in regard to the reference of the form field as I am typing off the cuff - you will want to look up the correct use of """ to wrap a form's field reference (I can't remember exactly).

    But Dlookup may not really be the best way to do this as it will be doing look ups all the time. When you select the course, why not then fill the Frequency field? ...I am assuming your FullList 'course' field is a lookup field to the Courses table. If so, include the Frequency field in that query which is behind the field in the form. Then in the AfterUpdate you can push the frequency value into the frequency field on the form (which I presume is bound to the frequency field in the fullList table) with code: Me.FrequencyFieldName = Me.CourseFieldName.column(2)
    (again that column value may not be correct - it may be 1)

    Hope this helps a little.

  3. #3
    ssanfu is offline Master of Nothing
    Windows XP Access 2000
    Join Date
    Sep 2010
    Location
    Anchorage, Alaska, USA
    Posts
    9,664
    It is a lot easier that you think.

    In the row source for the "Course" combo box, add the "Frequency".
    So the SQL would look like "SELECT ID, Course, Frequency FROM Courses"
    In the after update event of the "Course" combo box, enter
    Me.Frequency = Me.cboCourse.Column(2)

    The columns are zero based, so the first column = 0, the second column = 1, ....
    As soon as you select a course, the frequency will be pushed into the frequency text box. TaDa!!


    If you have problems, post the SQL of the course combo box. Also, it would help if you would include actual table and control names .

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. DLookup isn't working
    By cec in forum Access
    Replies: 7
    Last Post: 12-28-2012, 12:21 PM
  3. Replies: 3
    Last Post: 02-03-2012, 06:37 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