Results 1 to 3 of 3
  1. #1
    cuddles is offline Advanced Beginner
    Windows 7 64bit Access 2010 64bit
    Join Date
    May 2014
    Posts
    98

    Question Update Form after Find

    I have a form that allows the user to search my database and find data. The find works great and I am using a mainform for the listbox where the end-user wants to opt for drop-down or begin typing and have the information show-up because there are over 1000 possibilities. When they find what they want, the subform textboxes automaticallly fill in what is associated with that listbox selection. So now the update comes into play. The end-user notices that the month and frequency need to be changed because the program is going to run in a different month and have a different frequency. So, they click on the textbox and type in ongoing for the frequency and the month is going to be Jun to start. By doing this, the data is now updated in the main table. The problem is while I am testing this I do see the change but the ID for each item does not change.

    Example: The frequency table has 12 frequencies all with a distinct ID for the primary key. The month table 12 months with a distinct ID for the primary key. These have a relationship to the maintable. So, if in the main table the frequency for what the end-user changed USED to be Frequency one-time and the month march, the ID would be 1 for freqID and 3 for MthID. When the end-user decides they need to update this information, they type in ongoing and then Jun and ongoing should change to freqID 2 and 6 for MthID, but it does not in the maintable. The data they entered changed but the primary key associated with their change did not. This is because I know I need an afterupdate event for that textbox that is changing and I do have the primary key fields for each table that are not visible to end-user because they would have no clue what they mean. So, I hid them and I can see them on design view.

    I am just not sure how to code my afterupdate event. I am sure it has to be something like



    Code:
    private sub freq_afterupdate()
    if a new frequency is selected then take the value of what is typed in and run a query on the table and put in the correct primary key value
    I am just not entirely sure how to do it. My main form does have a query that connects the maintable to all the other tables in the database.

  2. #2
    ranman256's Avatar
    ranman256 is offline VIP
    Windows Vista Access 2010 32bit
    Join Date
    Apr 2014
    Location
    Kentucky
    Posts
    9,549
    Run an update query. (tho not in the freq_afterupdate() event...they may choose incorrectly... maybe an update button?)
    anywho...
    If the record they are on has a key, then the event will run the query: quUpdFreqChg

    quUpdFreqChg.sql = Update tData Set [feq] = '" & form!frmMain!Freq & "' where tData.Key = " & form!frmMain!key

  3. #3
    cuddles is offline Advanced Beginner
    Windows 7 64bit Access 2010 64bit
    Join Date
    May 2014
    Posts
    98
    Wow. That will be a HUGE update query. I think I will just restrict changes to all the textboxes but ones that are intentionally blank. If they want to change something that is already there for the time being they can just come to me and I will do it. I am not well versed enough on how to code something so large.

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

Similar Threads

  1. Find and update multiple values
    By chemthethriller in forum Forms
    Replies: 3
    Last Post: 04-22-2014, 01:15 PM
  2. Replies: 3
    Last Post: 04-02-2014, 10:31 AM
  3. Replies: 2
    Last Post: 06-14-2013, 12:56 PM
  4. Replies: 1
    Last Post: 05-23-2012, 10:05 AM
  5. Replies: 2
    Last Post: 10-20-2011, 08:31 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