Combo refresh form problem?

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

Hello,

I have a main form with a combo that drops down names, eg name of doctor. I
also have an add doctor command button on the main form that opens a form (in
add mode) and adds doctors to the doctors table.
Currently, what I have now is a macro that closes the main form, opens the
add doctor form, and then when the user clicks the close button, it re-opens
the main form. The addition is successful (the new doctor now shows in the
combo drop-down) BUT when the main form re-opens, it does not return to the
current record I was working on. Is there a way to do this? Is there a way to
add the Dr. without closing the main form? I may have multiple times where
this may happen, eg. when a pharmacy name is not there, when a drug name is
not there, etc.

Hopeful,

Rookie.
 
First open the second form without closing the first form. Once all
data is entered into the second form requery the control on the first
form. The OnExit property of the second form enter this code.

Dim MyControl As Control
Set MyControl = Forms!FormName!ControlName
MyControl.Requery

Replace FormName with the name of the first form and ControlName with
the name of the combo box.

Hope this helps.
 
Hey Penguin,
Thanks for your reply...
I'm getting a runtime error 2465 that says Access can't find the field in my
expression. When I click debug, the line:
Set MyControl = Forms!frmclients!doctors is highlighted.
I forgot to let you know that the combo is in a subform of the main
form...would that affect the statement?
My main form is named frmclients; my subform called tbltraining subform.
In the subform, I have a drop down combo called doctors.

Feel like I'm really close...

John.
 
Try this:

Dim MyControl As Control
Set MyControl = Forms!frmclients!tbltraining.Form!doctors
MyControl.Requery
 
Back
Top