Page 2 of 2 FirstFirst 12
Results 16 to 25 of 25
  1. #16
    AnandKhinvasara is offline Advanced Beginner
    Windows 7 64bit Access 2007
    Join Date
    Jul 2014
    Posts
    31

    Its all about the approach.

    You were wrong in two approaches
    1. Trying to edit a textbox that is linked a listbox column,which is based on a query.


    2. Thinking that editing the textbox with expression, - will actually change the value in the table.

    Please remember
    1. query fields can't be edited, and values changed won't reflect in the table.
    2. Trying to put a value in a textbox field that is not bound to a field in the table, will not change the value in the original table in any way.

    Better approach
    ->Make a simple form that has fields bound to the table
    ->Have a command button on your main form that opens up form above with filter applied as below.

    DoCmd.OpenForm "tblHRMSEdit", acNormal, , WhereCondition:="ItemNo=" & Me.Text209
    ->Make changes in the form that opens up. This will actually save the value in the table.

    You can refresh the main form contraols after getting focus back, so that it reflects the values you have changed.
    This can be on Close Event of tblHRMSEdit form, or on Activate/GotFocus/DatasetChage events of Main Form (you would need to play around a bit).

    LEt me know if this helped. Have attached MDB with "Edit Record" button.
    Attached Files Attached Files

  2. #17
    AnandKhinvasara is offline Advanced Beginner
    Windows 7 64bit Access 2007
    Join Date
    Jul 2014
    Posts
    31
    Other way of doing this is replacing all expression textboxes below the listbox, by a subForm linked to tblHRMS.
    On Form_Load of this form, put Form.Filter = -1 so that it loads without showing any data when it first loads.

    Then on click event of listbox, apply filter to this subform and requery it , so that it shows corresponding data.

    This approach will work with the design that you currently have (without addition of command button), however it obviously has more work to do than previous method.

    Take your best decision to get this through.

  3. #18
    June7's Avatar
    June7 is offline VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    53,646
    Anand, what you suggest does not require a subform. It can be done with the single form with the edits I suggested in posts 9 and 11.

    Gatsby, did you follow the suggestions? Did you remove the expressions and bind textboxes to fields? Did you change the DataEntry property to No. Did you edit the VBA code?
    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.

  4. #19
    gatsby is offline Competent Performer
    Windows 7 32bit Access 2010 32bit
    Join Date
    Jan 2013
    Posts
    114
    Quote Originally Posted by AnandKhinvasara View Post
    You were wrong in two approaches
    1. Trying to edit a textbox that is linked a listbox column,which is based on a query.
    2. Thinking that editing the textbox with expression, - will actually change the value in the table.

    Please remember
    1. query fields can't be edited, and values changed won't reflect in the table.
    2. Trying to put a value in a textbox field that is not bound to a field in the table, will not change the value in the original table in any way.

    Better approach
    ->Make a simple form that has fields bound to the table
    ->Have a command button on your main form that opens up form above with filter applied as below.

    DoCmd.OpenForm "tblHRMSEdit", acNormal, , WhereCondition:="ItemNo=" & Me.Text209
    ->Make changes in the form that opens up. This will actually save the value in the table.

    You can refresh the main form contraols after getting focus back, so that it reflects the values you have changed.
    This can be on Close Event of tblHRMSEdit form, or on Activate/GotFocus/DatasetChage events of Main Form (you would need to play around a bit).

    LEt me know if this helped. Have attached MDB with "Edit Record" button.


    Thanks for help AnandKhinvasara... For now, ill use this approach. if i still have time then i will revise it again. Thanks again Anand.

  5. #20
    gatsby is offline Competent Performer
    Windows 7 32bit Access 2010 32bit
    Join Date
    Jan 2013
    Posts
    114
    Quote Originally Posted by June7 View Post
    Anand, what you suggest does not require a subform. It can be done with the single form with the edits I suggested in posts 9 and 11.

    Gatsby, did you follow the suggestions? Did you remove the expressions and bind textboxes to fields? Did you change the DataEntry property to No. Did you edit the VBA code?

    in my previous reply, yes i did. i set the dataentry property to NO, i tried to edit the VBA code (requery) but still no luck. im not sure if what i did was right but still not working.

  6. #21
    AnandKhinvasara is offline Advanced Beginner
    Windows 7 64bit Access 2007
    Join Date
    Jul 2014
    Posts
    31
    June7, you are right. I missed checking that main form does not have any recordsource, so Gatsby can directly bind textboxes to fields - instead of putting a subform in future, when he decides to revamp the design.

    Gatsby, welcome and glad you liked the solution. Please mark thread as solved if you have no further query.

    cheers !

  7. #22
    gatsby is offline Competent Performer
    Windows 7 32bit Access 2010 32bit
    Join Date
    Jan 2013
    Posts
    114
    Quote Originally Posted by AnandKhinvasara View Post
    June7, you are right. I missed checking than main form does not have any recordsource, so Gatsby can directly bound textboxes to fields - instead of putting a subform in future, when he decides to revamp the design.

    Gatsby, welcome and glad you liked the solution. Please mark thread as solved if you have no further query.

    cheers !

    yes thanks... posted another thread in Forms. i hope its the correct category. its regarding my combo boxes.

  8. #23
    June7's Avatar
    June7 is offline VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    53,646
    Oh, did I mention that you need to bind the form - set RecordSource property to the parameterized query then bind the textboxes to fields?
    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.

  9. #24
    AnandKhinvasara is offline Advanced Beginner
    Windows 7 64bit Access 2007
    Join Date
    Jul 2014
    Posts
    31
    June7, binding to parameterized query may not work. Remember he needs to edit the field. Gatsby needs to set recordsource to Table only. Please correct me if I am wrong

  10. #25
    June7's Avatar
    June7 is offline VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    53,646
    Binding to query should work just fine, as long as it is an editable query. A simple SELECT pulling only from the one table is an editable query.
    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.

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

Similar Threads

  1. Input Box Bound to Expression
    By CementCarver in forum Forms
    Replies: 13
    Last Post: 10-12-2013, 04:13 PM
  2. Replies: 13
    Last Post: 01-11-2012, 09:44 PM
  3. Control can't be edited
    By TracyBell in forum Database Design
    Replies: 11
    Last Post: 05-17-2011, 01:38 PM
  4. Replies: 1
    Last Post: 06-23-2010, 09:05 AM
  5. Replies: 2
    Last Post: 07-30-2009, 08:02 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