Results 1 to 13 of 13
  1. #1
    JonoGee is offline Novice
    Windows 10 Office 365
    Join Date
    Aug 2022
    Posts
    27

    DLookup Expression or VBA OR Query! Nothings working....!! Please Help

    HI all, I am at my wits end with this one and it strikes me as it should be so simple...


    I am basically trying to do the equivalent of an Index/Match or Vlookup would do in Excel...
    I have tried DLookup's and Queries and no matter what I do it seems i always get syntax errors..... To be honest the simple ability to do this seemingly small thing is holding me back massively on this cry fest!

    I have attached an screenshot explaining what i want to do combined with the description below...
    Basically, I want to look for the Yellow Circled Code in FORM_1 (Bill_Payment_Currency_Code), in this case, "INR", in TABLE_1, then return the value of whatever is in the column "Currency_to_GBP_Rate_Multiplier" (Cell Highlighted in green) so in this case 0.011.
    Then, I want that value (0.011) to be displayed in the green circled box named "Bill_Payment_Currency_To_GBP_Rate".

    I am sure there would be a best practise way to do this, Query, Expression or VBA but i literally can't get any success at all...Click image for larger version. 

Name:	JPG_DLookup_Cluster_F.jpg 
Views:	20 
Size:	133.7 KB 
ID:	48590

  2. #2
    ranman256's Avatar
    ranman256 is offline VIP
    Windows Vista Access 2010 32bit
    Join Date
    Apr 2014
    Location
    Kentucky
    Posts
    9,526
    'the where clause using a string field
    sWhere = "[field]='" & txtBox & "'"

    'the where clause using a numeric field
    sWhere = "[field]=" & txtBox

    =Dlookup ("[field2return]", "[TableOrQry]",sWhere)

    but for combo boxes, you dont event need code,
    the value in Combo1, can fill the value in combo2. Combo1 has 2 columns, and places the value picked in combo2

    Code:
    sub combo1_afterupdate()
    combo2 = combo1.column(1)   'in vb, columns begin with zero , not 1)
    end sub

  3. #3
    JonoGee is offline Novice
    Windows 10 Office 365
    Join Date
    Aug 2022
    Posts
    27
    OK. I have no idea what all that meant above the Combo boxes bit, but Combo boxes sounds like it would do the job. Let me give that a go. Thank you.

  4. #4
    JonoGee is offline Novice
    Windows 10 Office 365
    Join Date
    Aug 2022
    Posts
    27
    SO i have tried that and now the Combobox1 still opens up the list of choices, but will now not let me pick one..
    Any ideas? Obviously when I am in Form View and not as shown below

    Code:
    Private Sub Bill_Payment_Currency_AfterUpdate()
    Bill_Payment_Currency_To_GBP_Rate = Bill_Payment_Currency.Column(1)   'in vb, columns begin with zero , not 1)
    End Sub
    JPG Screenshot attached....Click image for larger version. 

Name:	JPG_DLookup_Cluster_F_2.jpg 
Views:	18 
Size:	98.8 KB 
ID:	48591

  5. #5
    Micron is offline Virtually Inert Person
    Windows 10 Access 2016
    Join Date
    Jun 2014
    Location
    Ontario, Canada
    Posts
    12,818
    You have 3 green indicators telling you something is wrong. What are those messages? Might help to see the combo row source as well.
    The more we hear silence, the more we begin to think about our value in this universe.
    Paraphrase of Professor Brian Cox.

  6. #6
    JonoGee is offline Novice
    Windows 10 Office 365
    Join Date
    Aug 2022
    Posts
    27
    I don't know anything about three status indicators. Whats that like>? lol.
    This is the Combobox1 Row Source that was Auto Generated...
    Click image for larger version. 

Name:	JPG_DLookup_Cluster_F_3.jpg 
Views:	18 
Size:	104.6 KB 
ID:	48592

  7. #7
    Micron is offline Virtually Inert Person
    Windows 10 Access 2016
    Join Date
    Jun 2014
    Location
    Ontario, Canada
    Posts
    12,818
    No idea what your 1st comment means. Your first pic clearly shows the indicators?
    The rowsource is partially evident in that first pic (in the property sheet) and begins with SELECT. That's what I was referring to.
    The more we hear silence, the more we begin to think about our value in this universe.
    Paraphrase of Professor Brian Cox.

  8. #8
    Gicu's Avatar
    Gicu is offline VIP
    Windows 10 Access 2010 32bit
    Join Date
    Jul 2015
    Location
    Kelowna, BC, Canada
    Posts
    4,122
    In your first post you have #Name? in the last two fields meaning the controls are bound to non-existing fields (in the form's record source). Same thing probably with Bill_Payment_Currency_Code, make sure it exists in the form's source. And you do not need to make CurrencyRate a combo, you can leave it as a textbox and simply add =[Bill_Payment_Currency_Code].Column(1) to the control source property (assumes that "Bill_Payment_Currency_Code" is the name of the combo, make sure you rename it and it is bot combobox1).

    Cheers,
    Vlad Cucinschi
    MS Access Developer
    http://forestbyte.com/

  9. #9
    JonoGee is offline Novice
    Windows 10 Office 365
    Join Date
    Aug 2022
    Posts
    27
    Code:
    SELECT tbl_SETTINGS_FINANCE_Currencies.Id, tbl_SETTINGS_FINANCE_Currencies.Currency_Code, tbl_SETTINGS_FINANCE_Currencies.[Currency-Symbol], tbl_SETTINGS_FINANCE_Currencies.Currency_Name FROM tbl_SETTINGS_FINANCE_Currencies ORDER BY tbl_SETTINGS_FINANCE_Currencies.[Id];
    Oh Sorry, I have never noticed them before... I am colourblind,, but still I can't believe i have never nopticed those before..

  10. #10
    davegri's Avatar
    davegri is offline Excess Access
    Windows 11 Access 2019
    Join Date
    May 2012
    Location
    Denver
    Posts
    3,421
    Click image for larger version. 

Name:	mindicators.png 
Views:	18 
Size:	286.6 KB 
ID:	48593
    Micron's green indicators.

  11. #11
    JonoGee is offline Novice
    Windows 10 Office 365
    Join Date
    Aug 2022
    Posts
    27
    I am lost now... I have tried that but its just returning #Name?
    Click image for larger version. 

Name:	JPG_DLookup_Cluster_F_4.jpg 
Views:	18 
Size:	129.4 KB 
ID:	48594

  12. #12
    Join Date
    Jun 2010
    Location
    Belgium
    Posts
    1,046
    Maybe you can post a copy of your application with some dummy data in it?

  13. #13
    Gicu's Avatar
    Gicu is offline VIP
    Windows 10 Access 2010 32bit
    Join Date
    Jul 2015
    Location
    Kelowna, BC, Canada
    Posts
    4,122
    What is the record source of the form? #Name? means the record source (table or query) does not include the Bill_Payment_Currency_Code field.

    Cheers,
    Vlad Cucinschi
    MS Access Developer
    http://forestbyte.com/

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

Similar Threads

  1. Replies: 9
    Last Post: 04-14-2020, 04:03 AM
  2. Expression query not working
    By Chevy757IT in forum Queries
    Replies: 9
    Last Post: 05-09-2019, 06:05 AM
  3. Replies: 3
    Last Post: 08-17-2018, 07:56 AM
  4. Query Expression with IIF and DLOOKUP
    By bryan0 in forum Queries
    Replies: 7
    Last Post: 01-30-2014, 07:52 PM
  5. Expression not working in query
    By Bob Blooms in forum Access
    Replies: 4
    Last Post: 08-25-2012, 08:42 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