473,465 Members | 1,773 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

Please Help: Add a new record to the combo box and prompt to that record

51 New Member
I have a form call frmMedRec and on this form, I have a cbo box call Patient, then next to the cbo patient, I have a command button "Add a new patient". When the user click on this Add a New Patient Button, it opens a oop up form Add A new Patient, When the user click Save button on the Add a new Patient form, it closes the Add a new patient pop up form, and it adds this new patient to the cbo Patient box. However, the user has to re-select this new patient again, because the cbo box didn't prompt right at the new patient.
Any idea? I really appreciate everyone's help. Thanks!

Here is my code under the Save Button on the Pop Up form "Add a new patient":

Expand|Select|Wrap|Line Numbers
  1. Private Sub cmdSave_Click()
  2. If IsNull(txtPT_MRN) Then
  3.         MsgBox "Patient MRN is required!", vbInformation, "REQUIRED FIELD!"
  4.         [txtPT_MRN].SetFocus
  5. ElseIf IsNull(txtPT_Name) Then
  6.         MsgBox "Patient Name required!", vbInformation, "REQUIRED FIELD!"
  7.         [txtPT_Name].SetFocus
  8.  
  9. Else
  10.     MsgBox "Patient: " & [txtPT_MRN] & " " & [txtPT_Name] & " has been   added successfully!", vbInformation, "Patient has been added!"
  11.     DoCmd.Close acForm, "fdlgAddPatient", acSaveYes
  12.     [Forms]![frmMedRec]![cboMRN].SetFocus
  13.     [Forms]![frmMedRec]![cboMRN].Requery
  14.  
  15. End If
  16.  
  17. Exit Sub
  18. End Sub
Apr 25 '07 #1
3 1511
Rabbit
12,516 Recognized Expert Moderator MVP
So basically you want the combobox to be at the new patient after they add it through the form?

BEFORE the form closes, requery the combobox and set it's value to the new patient.

[Forms]![frmMedRec]![cboMRN] = Me.PatientName
Apr 25 '07 #2
elainenguyen
51 New Member
Thanks Rabit, It worked. You are such a big help!
Elaine
Apr 25 '07 #3
Rabbit
12,516 Recognized Expert Moderator MVP
Not a problem. Good luck.
Apr 25 '07 #4

Sign in to post your reply or Sign up for a free account.

Similar topics

4
by: Skully Matjas | last post by:
I am using the following code (created by the wizard) to allow to bring my form to a particular entery. But when I edit the entery (ex: put new information into a blank cell), it puts that record...
1
by: Skully Matjas | last post by:
Thank you for getting back to me. I am very new at this so i didnot understand what you said, here i will give as much cetails as possible: 1) The combo box i am using is combox39 2) I imported...
20
by: Jack Schitt | last post by:
I thought I was starting to get a handle on Access, until I tried doing something useful...now I'm stuck. I have a DB with two tables - to keep it simple I'll say that one is an Employee File...
2
by: edworboys | last post by:
I have designed a data entry form with a number of fields and a sub form. The first field (Country) is a combo box and the user selects a country. This, in turn reduces the number of options in the...
14
by: alwayshouston | last post by:
Hi All! I am working on this very small database and I am confused in the designing a simple form. I only have three tables in the database. First Table: tblExpense Columns: ExpenseID ;...
8
by: Steph | last post by:
Hi. I'm very new to MS Access and have been presented with an Access database of contacts by my employer. I am trying to redesign the main form of the database so that a button entitled...
1
by: No Spam | last post by:
Dear Access Users, I have a form with a combo box and a button on it. The combo box has a list of all the records in the database. When the user pushes the button, a macro runs that deletes...
9
by: Edwinah63 | last post by:
Hi everyone, Please let there be someone out there who can help. I have two BOUND combo boxes on a continuous form, the second being dependent on the first. I have no problem getting the...
12
by: Lnwolf | last post by:
Hello, I am having an issue with my synchronized combo boxes and don't know how to fix it. I have created two boxes and have made the synchronization work (the user clicks on the first box and...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.