Page 1 of 2 12 LastLast
Results 1 to 15 of 18
  1. #1
    Dal is offline Novice
    Windows 10 Office 365
    Join Date
    Nov 2023
    Posts
    12

    What DAO's Are Not Dynamic?

    DAO (Database Access Object is probably the wrong term but trying my best to explain). I need my db to be as dynamic as possible. I created a dLookup in a form referencing a table called tBills. I have just changed the name of the table to tBills2 & it seems that references in the expression editor are not dynamic. I know this is the case in VBA also. What do I need to be aware of the common pitfalls in db design?

    It is a text box coloured yellow. I imagine if had used the wizard it would be dynamic. But I'm trying to learn properly how it truly works. What would be the best way to enter a text box fed from another table so it is fully dynamic? I know I could use VBA but I want to keep VBA to a minimum as it seems that surely VBA is not required for this.

    Click image for larger version. 

Name:	1.png 
Views:	42 
Size:	35.4 KB 
ID:	51753



    Also I can't see the source properly. With lots of tables... similar fields can get confusing. The record source only shows the field; how do you find out the source table? Take 2nd pic e.g. showing MainHeaderID I cannot see the table source? Disregard the fMainHeaders at the top because this could be renamed/ deleted.

    Click image for larger version. 

Name:	2.png 
Views:	40 
Size:	23.0 KB 
ID:	51754

  2. #2
    June7's Avatar
    June7 is offline VIP
    Windows 10 Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,967
    Your attachments are invalid. EDIT: And they are now fixed.
    Last edited by June7; 04-30-2024 at 03:35 PM.
    How to attach file: http://www.accessforums.net/showthread.php?t=70301 To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression.

  3. #3
    Join Date
    Jan 2017
    Location
    Swansea,South Wales,UK
    Posts
    5,012
    The fact that you now have tbills2 sounds alarm bells. What happened to tbills?
    Please use # icon on toolbar when posting code snippets.
    Cross Posting: https://www.excelguru.ca/content.php?184
    Debugging Access: https://www.youtube.com/results?sear...bug+access+vba

  4. #4
    Dal is offline Novice
    Windows 10 Office 365
    Join Date
    Nov 2023
    Posts
    12
    Experimenting trying to learn.

  5. #5
    pbaldy's Avatar
    pbaldy is offline Who is John Galt?
    Windows XP Access 2007
    Join Date
    Feb 2010
    Location
    Nevada, USA
    Posts
    22,530
    FYI I deleted your moderated post since you'd already reposted the question and received replies. I was slow on the moderating, sorry.
    Paul (wino moderator)
    MS Access MVP 2007-2019
    www.BaldyWeb.com

  6. #6
    Dal is offline Novice
    Windows 10 Office 365
    Join Date
    Nov 2023
    Posts
    12
    No worries, it thought it was a repeated question because I posted a VBA solution I found.

  7. #7
    Micron is online now Virtually Inert Person
    Windows 10 Access 2016
    Join Date
    Jun 2014
    Location
    Ontario, Canada
    Posts
    12,822
    A bound control's source is the field. The form recordsource is the table or query, so if you want to know that, select the form and look at the data tab. That is the only way for bound controls.
    The more we hear silence, the more we begin to think about our value in this universe.
    Paraphrase of Professor Brian Cox.

  8. #8
    Dal is offline Novice
    Windows 10 Office 365
    Join Date
    Nov 2023
    Posts
    12
    Thanks but how do you know what table/ query if you have many similar fields. There does not appear to be an indicator.

  9. #9
    Micron is online now Virtually Inert Person
    Windows 10 Access 2016
    Join Date
    Jun 2014
    Location
    Ontario, Canada
    Posts
    12,822
    Not sure I understand your question. If I build a form and its recordsource is a table or query, I know which table it is by looking at the form or report recordsource as I stated. If you have several tables that have fields with the same name, it either means you need to adopt a better naming convention, or your tables are not sufficiently normalized. The former often results from using names like ID for the primary key field in every table. ID tells you nothing about the field or the table it's in. PO_ID or PoID or something similar tells you it's the ID field in the Purchase Order table, and that I would know just from looking at the control source property. Other field names would not help so much, such as "Length", so just look at the form record source. If none of that helps, maybe post a pic of your relationships so that we can see some field names that you have.
    The more we hear silence, the more we begin to think about our value in this universe.
    Paraphrase of Professor Brian Cox.

  10. #10
    June7's Avatar
    June7 is offline VIP
    Windows 10 Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,967
    If by dynamic you mean it will calculate for each record, expression needs to reference value from current record. Complete the WHERE argument for your DLookup with concatenation.

    =DLookup("Bill", "tBills", "BillID=" & [BillID])
    How to attach file: http://www.accessforums.net/showthread.php?t=70301 To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression.

  11. #11
    Join Date
    Jan 2017
    Location
    Swansea,South Wales,UK
    Posts
    5,012
    I *think* the o/p is talking about, they had a dlookup on tbills but then had to change it to tbills2, but their dlookup and anything else did not adjust to suit?
    Please use # icon on toolbar when posting code snippets.
    Cross Posting: https://www.excelguru.ca/content.php?184
    Debugging Access: https://www.youtube.com/results?sear...bug+access+vba

  12. #12
    Gicu's Avatar
    Gicu is offline VIP
    Windows 10 Access 2013 32bit
    Join Date
    Jul 2015
    Location
    Kelowna, BC, Canada
    Posts
    4,123
    I think the OP is looking for Name Autocorrect or similar functionality, it has improved since was first introduced but many programmers still shy away from it:
    https://support.microsoft.com/en-us/...4-a93c10a9d98b
    http://allenbrowne.com/bug-03.html
    Cheers,
    Vlad Cucinschi
    MS Access Developer
    http://forestbyte.com/

  13. #13
    June7's Avatar
    June7 is offline VIP
    Windows 10 Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,967
    Auto-correct will not modify references in quotes. I think OP's real problem is invalid DLookup expression. See post 10.
    How to attach file: http://www.accessforums.net/showthread.php?t=70301 To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression.

  14. #14
    Dal is offline Novice
    Windows 10 Office 365
    Join Date
    Nov 2023
    Posts
    12
    Quote Originally Posted by June7 View Post
    Auto-correct will not modify references in quotes. I think OP's real problem is invalid DLookup expression. See post 10.
    Correct, the problem is the arguments of DLookup are provided in strings. I am looking for a dynamic solution.

    Quote Originally Posted by Welshgasman View Post
    I *think* the o/p is talking about, they had a dlookup on tbills but then had to change it to tbills2, but their dlookup and anything else did not adjust to suit?
    Correct

    Quote Originally Posted by Gicu View Post
    I think the OP is looking for Name Autocorrect or similar functionality, it has improved since was first introduced but many programmers still shy away from it:
    https://support.microsoft.com/en-us/...4-a93c10a9d98b
    http://allenbrowne.com/bug-03.html
    You've grasped the issue completely, thank you, perfectly linked article many thanks.

    To others in the future: to see the main source of the form click the top left black rectangle selecting the entire form, Properties > Data > Record Source - the main source of the entire form is listed here.

  15. #15
    Micron is online now Virtually Inert Person
    Windows 10 Access 2016
    Join Date
    Jun 2014
    Location
    Ontario, Canada
    Posts
    12,822
    To others in the future: to see the main source of the form click the top left black rectangle selecting the entire form, Properties > Data > Record Source - the main source of the entire form is listed here.
    As was stated in post 7.
    The more we hear silence, the more we begin to think about our value in this universe.
    Paraphrase of Professor Brian Cox.

Page 1 of 2 12 LastLast
Please reply to this thread with any new information or opinions.

Similar Threads

  1. dynamic sql using control Name
    By gammaman in forum Programming
    Replies: 5
    Last Post: 11-28-2016, 12:40 PM
  2. Dynamic Form, Dynamic labels/ captions?
    By JFo in forum Programming
    Replies: 15
    Last Post: 10-12-2011, 08:33 PM
  3. Dynamic functions
    By bubu678 in forum Programming
    Replies: 2
    Last Post: 11-09-2010, 09:55 PM
  4. Dynamic reports
    By amonadi in forum Reports
    Replies: 1
    Last Post: 10-29-2010, 01:32 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