macro not automaticlly updating combo box

  • Thread starter Thread starter jeremy0028
  • Start date Start date
J

jeremy0028

I have a main form called frm people which has a command button called
add charges which has the following code

Private Sub Add_Charge_Click()
On Error GoTo Err_Add_Charge_Click

Dim stDocName As String
Dim stLinkCriteria As String

stDocName = "frmCharges"
DoCmd.OpenForm stDocName, , , stLinkCriteria

Exit_Add_Charge_Click:
Exit Sub

Err_Add_Charge_Click:
MsgBox Err.Description
Resume Exit_Add_Charge_Click

End Sub

When pressed opens a form called frmcharges. in the form i have 2
combo boxs

1st is called personID which has the following

SELECT [tblPeople].[PersonID], [tblPeople].[LastName]&", "&
[tblPeople].[FirstName]&" "& [tblPeople].[MiddleName] FROM
[tblPeople];

In the after update event of the combo box i have a macro named Macro1
in the macro has a requery event to the billedTo combo box

The default value has the following =[Forms]![frmPeople]![txtPersonID]


The second combo box is BilledTo which displays the insurance name of
the patient.

SELECT tblPeopleInsurance.GuaranterID, tblPeopleInsurance.PersonID,
tblPeopleInsurance.InsuranceName
FROM tblPeopleInsurance
WHERE (((tblPeopleInsurance.PersonID)=[tblCharges].[PersonID]));

This works fine however i always have to select the name from the
personid comb box in the frmcharge before the BilledTo combo box
updates with the patients Insurance.

What I want to do is have the BilledTo automatically update when i
select add charge command button from the frm called frmPeople.

Is there any possiblities.


Thanks in advance.
 
Jeremy,

Do you mean that you want the BilledTo combobox to relate to the
PersonID of the current record on the frmPeople form, as at the time
that you click the Add Charge button? If so, you should be able to set
the Row Source of the BilledTo combobox to like this...
SELECT GuaranterID, PersonID, InsuranceName
FROM tblPeopleInsurance
WHERE PersonID=[Forms]![frmPeople]![PersonID]
 
Back
Top