Results 1 to 7 of 7
  1. #1
    s@s is offline Novice
    Windows 10 Access 2016
    Join Date
    Nov 2020
    Posts
    12

    how to set a field value of my form record?

    hi all,



    so i got a form and i display some query fields there.
    one of the fields (entity_type) i dont display it as i use different forms per entity type hence the field value is implied from the form.

    now when the user enters a new record i want to set rs!entity_type = the proper value teach time depending on the form.

    i managed to do this by having a hidden textbox bound to entity_type and set it on the before_insert event to the value i need.

    but what if i dont want to have the bound textbox there at all?

    how can this be done?

    thx!

  2. #2
    Ajax is offline VIP
    Windows 10 Access 2010 32bit
    Join Date
    Mar 2015
    Posts
    8,706
    have you tried in the form before update to just set the field value rather than the textbox value?

    or if you have a hidden textbox, set the default value for the control - no code required

  3. #3
    ssanfu is offline Master of Nothing
    Windows 10 Access 2010 32bit
    Join Date
    Sep 2010
    Location
    Anchorage, Alaska, USA
    Posts
    9,033
    Quote Originally Posted by s@s View Post
    ....now when the user enters a new record i want to set rs!entity_type = the proper value teach time depending on the form.

    i managed to do this by having a hidden textbox bound to entity_type and set it on the before_insert event to the value i need.
    Nothing wrong with this. I have done this when I have a TimeStamp field. (but I used the before update event.)



    Quote Originally Posted by s@s View Post
    .....one of the fields (entity_type) i dont display it as i use different forms per entity type hence the field value is implied from the form.
    But I don't understand why would you use multiple forms just because the entity_type field can have different values. Wouldn't it be easier to have one form and have a combo box control to select the value?
    Or depending on how the form was called (different buttons), there could be code to add the proper value to the entity_type field.

    Maybe you would expound a little on your dB/process?
    HTH
    -----
    Steve
    --------------------------------
    "Veni, Vidi, Velcro"
    (I came; I saw; I stuck around.)

  4. #4
    s@s is offline Novice
    Windows 10 Access 2016
    Join Date
    Nov 2020
    Posts
    12
    Hi, thx both for the replies






    Quote Originally Posted by Ajax View Post
    have you tried in the form before update to just set the field value rather than the textbox value?

    Yes but unsuccesfully, in essence this is what i'am asking. what i tried was to set an rs to the record source of the form and try to update the entitytype on the before update. but this updates the first record not the new that the user is creating. as you understand i havnt figured out how to reference the form record directly instead of via the form controls.




    Quote Originally Posted by ssanfu View Post
    Nothing wrong with this. I have done this when I have a TimeStamp field. (but I used the before update event.)
    But I don't understand why would you use multiple forms just because the entity_type field can have different values.



    Well maybe this is not the best idea but i got a table for all entity types common fields and one table for each entity type's "personal" fields". so in other words for each entry i want to display different set of fields. in order to have a "clean" form i made one for each type with the required form controls only. besides, "clean form" is the same reason i want to reference the entity type field directly and not via the hidden text box!

  5. #5
    Ajax is offline VIP
    Windows 10 Access 2010 32bit
    Join Date
    Mar 2015
    Posts
    8,706
    i tried was to set an rs to the record source of the form and try to update the entitytype on the before update.
    not sure why you are setting a rs - providing entitytype is returned in your form recordset even if you don't have a bound control for it, hidden or otherwise, all you needs is

    me!entitytype=3

    if this does not work for you, suggest provide more detail - your form recordsource, the code you are trying to use.

  6. #6
    s@s is offline Novice
    Windows 10 Access 2016
    Join Date
    Nov 2020
    Posts
    12
    ... you could not be more correct!

    Due to my inexperience i didnt realize that me.entity_type refers to the record and not to the form control (as i didnt rename the control to txtEntity_type) and i didnt even try this till you mentioned it! :/

    i fill so dumb, it was in front of my eyes and i didnt try it!

    thx both for the reply again!

  7. #7
    Ajax is offline VIP
    Windows 10 Access 2010 32bit
    Join Date
    Mar 2015
    Posts
    8,706
    it's all a learning experience!

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

Similar Threads

  1. Replies: 3
    Last Post: 10-26-2018, 05:16 AM
  2. Replies: 3
    Last Post: 11-28-2016, 03:17 PM
  3. Replies: 5
    Last Post: 10-18-2016, 06:00 AM
  4. Replies: 1
    Last Post: 01-13-2014, 12:11 AM
  5. Replies: 6
    Last Post: 04-17-2012, 10: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 - Senior Forums