Page 1 of 2 12 LastLast
Results 1 to 15 of 22
  1. #1
    Synergy.ron@gmail.com is offline Competent Performer
    Windows 10 Access 2016
    Join Date
    Oct 2020
    Location
    washington
    Posts
    126

    Question persistant / field....?

    i have a membership app. (for non-profit organizations across the usa. in this app i have a Utility table that holds 2 fields: default [area_code] and [defaultzipCode].

    the problem: i want the user to add values to these two fields which will persist when the next time the app is started.



    so far i am thinking i need to create a recordset to manually write these values to the table. but i haven't quite figured out the syntax yet. Attachment 44989

  2. #2
    orange's Avatar
    orange is offline Moderator
    Windows 10 Office 365
    Join Date
    Sep 2009
    Location
    Ottawa, Ontario, Canada; West Palm Beach FL
    Posts
    16,716
    ?? If you want a value to be persistent, then saving values to a table seems correct. But I don't see what the Randomize etc is meant to do other than create some test data.

    Your syntax is incorrect in my view.
    Dim db as DAO.database
    Dim rs as DAO.recordset

    put your DAO on the Dim not the set.

    Also you need a left bracket after db.openrecordset("

  3. #3
    Micron is offline Virtually Inert Person
    Windows 10 Access 2016
    Join Date
    Jun 2014
    Location
    Ontario, Canada
    Posts
    12,737
    I cannot recall ever using As over =
    Set db = CurrentDb ?

    Why so much code? Are users editing tables directly? If there is a form involved and the fields are bound to it, you validate the form data. Rather than prompt "do you want to keep the defaults" I'd just remove them and make those fields required, or don't bother at all. Defaults are for when it doesn't really matter or the field entry will be repetitive IMO.
    The more we hear silence, the more we begin to think about our value in this universe.
    Paraphrase of Professor Brian Cox.

  4. #4
    Synergy.ron@gmail.com is offline Competent Performer
    Windows 10 Access 2016
    Join Date
    Oct 2020
    Location
    washington
    Posts
    126
    re:defaults. the main reason for them is to minimize data input. the user base is 'guys in their 60-80's.Attachment 44991

    Attachment 44992 the current problem is Access seems to produce a syntax err when I reference rs.field

  5. #5
    orange's Avatar
    orange is offline Moderator
    Windows 10 Office 365
    Join Date
    Sep 2009
    Location
    Ottawa, Ontario, Canada; West Palm Beach FL
    Posts
    16,716

  6. #6
    Micron is offline Virtually Inert Person
    Windows 10 Access 2016
    Join Date
    Jun 2014
    Location
    Ontario, Canada
    Posts
    12,737
    I think your issue is that you have left off "Then".
    No telling what you're trying to do with that code. You can't edit or append to a DAO recordset unless you prep it first.
    Post code using code tags (# on forum post toolbar) and indentation. Pictures are not much help and are actually more work for you.
    The more we hear silence, the more we begin to think about our value in this universe.
    Paraphrase of Professor Brian Cox.

  7. #7
    Synergy.ron@gmail.com is offline Competent Performer
    Windows 10 Access 2016
    Join Date
    Oct 2020
    Location
    washington
    Posts
    126
    Quote Originally Posted by Micron View Post
    I think your issue is that you have left off "Then".
    No telling what you're trying to do with that code. You can't edit or append to a DAO recordset unless you prep it first.
    Post code using code tags (# on forum post toolbar) and indentation. Pictures are not much help and are actually more work for you.
    I ran across this articule on "persistence". Is this worth the effort ? https://bytes.com/topic/access/insig...ting-recordset

  8. #8
    Micron is offline Virtually Inert Person
    Windows 10 Access 2016
    Join Date
    Jun 2014
    Location
    Ontario, Canada
    Posts
    12,737
    the problem: i want the user to add values to these two fields which will persist when the next time the app is started.
    You have these 2 fields in the table. A user creates a record in that table and either the defaults you assigned are stored in that record in those fields or they are superseded by user input. I don't see the issue. My analogy is that you're looking at rockets to go to the grocery store.

    One day you might find that a zip code won't go into your field: Zip+4 codes for instance. Might be better off as text.
    The more we hear silence, the more we begin to think about our value in this universe.
    Paraphrase of Professor Brian Cox.

  9. #9
    Synergy.ron@gmail.com is offline Competent Performer
    Windows 10 Access 2016
    Join Date
    Oct 2020
    Location
    washington
    Posts
    126

    Question recordset reference causes err

    Still on the path to understanding reordset syntax....... thanks to steve bishop and others. Currently i am openin a recordet based on my 'utility' table one field on the record det id 'serial . but using rs.serial to reference it causes an error.

    what am i missing???? thanks

  10. #10
    Micron is offline Virtually Inert Person
    Windows 10 Access 2016
    Join Date
    Jun 2014
    Location
    Ontario, Canada
    Posts
    12,737
    Serial is not a member of a recordset - it is a member of the recordset's fields collection. Try
    rs.fields("serial")

    EDIT- Lots of errors in that code. Try compiling it to see where they are.
    The more we hear silence, the more we begin to think about our value in this universe.
    Paraphrase of Professor Brian Cox.

  11. #11
    orange's Avatar
    orange is offline Moderator
    Windows 10 Office 365
    Join Date
    Sep 2009
    Location
    Ottawa, Ontario, Canada; West Palm Beach FL
    Posts
    16,716
    Your graphic in post 4 shows serialNum as the column name.
    As per post 5, try rs!serialNum or using the syntax suggested by micron rs.fields("serialNum")
    Last edited by orange; 04-15-2021 at 04:59 PM. Reason: corrected post 1 to 4

  12. #12
    Micron is offline Virtually Inert Person
    Windows 10 Access 2016
    Join Date
    Jun 2014
    Location
    Ontario, Canada
    Posts
    12,737
    There is no "serialNum" in the posted db in the whole project. Now it seems to be "serial".
    The more we hear silence, the more we begin to think about our value in this universe.
    Paraphrase of Professor Brian Cox.

  13. #13
    Synergy.ron@gmail.com is offline Competent Performer
    Windows 10 Access 2016
    Join Date
    Oct 2020
    Location
    washington
    Posts
    126
    still getting errs. i wish there was a source on how to use recordsets and their syntax and 'gotcha's. anyone know of such a source?

  14. #14
    orange's Avatar
    orange is offline Moderator
    Windows 10 Office 365
    Join Date
    Sep 2009
    Location
    Ottawa, Ontario, Canada; West Palm Beach FL
    Posts
    16,716

  15. #15
    Micron is offline Virtually Inert Person
    Windows 10 Access 2016
    Join Date
    Jun 2014
    Location
    Ontario, Canada
    Posts
    12,737
    or post an up to date db.
    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. Replies: 21
    Last Post: 09-29-2017, 01:30 PM
  2. Replies: 6
    Last Post: 06-26-2015, 08:55 PM
  3. Replies: 17
    Last Post: 03-16-2014, 10:52 PM
  4. Replies: 3
    Last Post: 12-27-2013, 02:33 PM
  5. Replies: 1
    Last Post: 03-03-2012, 10:17 PM

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