Results 1 to 3 of 3
  1. #1
    jondavidf is offline Advanced Beginner
    Windows 7 64bit Access 2007
    Join Date
    Jun 2012
    Posts
    57

    Combo box tied to data entry

    Hey all,

    I've created a form to be used for data entry that opens to a blank (new) record. I'm trying to create a combo box (Study ID on left) that when a value from the drop-down is selected the user can enter data to create a new "Encounter".

    What my combo box does so far:

    1 - Passes the value (from another table) to the Study_ID field on the right side of the form (which will later be hidden).

    2 - Refreshes the subform query to show previous "encounters".

    Problems I'm having:



    1 - Instead of adding a new record the combo box brings up the last record and tries to modify that one. Whenever I set the combo box to also "GoTo Record -> New" it also clears the value from both Study_ID fields, defeating the purpose of passing the value to Study_ID on the right.

    2- Also it seems to add entries to the associated table without me intentionally doing so (see the blank record in the query). I'd like the record to remain unsaved until I select the command box "Save Encounter".

    Any help is tremendously appreciated.

    Thanks!!

    Click image for larger version. 

Name:	frmEncounterHelp.PNG 
Views:	19 
Size:	14.8 KB 
ID:	34012

  2. #2
    June7's Avatar
    June7 is offline VIP
    Windows 10 Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    53,771
    Record is committed to table when: 1. close table/query/form or 2. move to another record or 3. run code to save.

    In a linked form/subform arrangement, moving to the subform commits the parent record.

    After entering the BMI, focus goes to new record therefore the record just entered is committed. Then when you click the button, another record (with zeros) is committed.

    The combobox is UNBOUND? Controls used to input search/filter criteria should be UNBOUND.

    Values are cleared with "GoTo Record -> New" because you move to a new record row. Why would you expect otherwise?
    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
    jondavidf is offline Advanced Beginner
    Windows 7 64bit Access 2007
    Join Date
    Jun 2012
    Posts
    57
    Thanks June! I believe everything is now functioning properly. In case anyone else is interested or has any suggestions for improvement I did the following:

    1 - Removed the action to pass the combo box to Study_ID.

    2 - Set macro for combo box 'On Click' event to GoToRecord -> New, and RunMenuCommand -> Refresh.

    3 - Set property of qryPrevEncounters (which is the subform) Study_ID field to Criteria -> [Forms]![frmEncounters]![boxStudyID].

    Now whenever a new value is selected from the combo box previous encounters for that ID is shown on the subform query, yet the values in the main form remain blank except the combo box which remains at the value the user selected.

    4 - Set macro of cmdSaveEncounter 'On Click' event to

    a. SetProperty of Study_ID from Value =[boxStudyID]
    b. RunMenuCommand -> SaveRecord
    c. RunMenuCommand -> Refresh
    d. GoToRecord -> New

    5 - I also added a delete query to delete any records from the tblEncounters without a date and coded the cmdSaveEncounter to run this after it ran the commands above. That way, if a user clicked "Save Encounter" without a date it would technically save but then delete that record.

    Now, any time the combo box is changed you can see all previous encounters for that Study ID but with a blank record displayed on the main form. A new record will not be added until the user enters data in the main form. Also BMI is calculated based off height and weight in the qryPrevEncounters.

    I know this is probably not the best way to set up the macros and all, but with my limited coding ability it's what I came up with and seems to work.

    Click image for larger version. 

Name:	frmEncounterPrevEncountersQry.PNG 
Views:	13 
Size:	15.7 KB 
ID:	34031

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

Similar Threads

  1. Replies: 1
    Last Post: 07-20-2016, 10:01 PM
  2. Replies: 1
    Last Post: 02-24-2015, 06:54 PM
  3. Replies: 7
    Last Post: 02-08-2014, 12:31 PM
  4. Replies: 1
    Last Post: 09-30-2013, 11:47 AM
  5. Replies: 33
    Last Post: 01-13-2012, 07:44 AM

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