Filtering form data by selection made in combo box

NRP

New Member
Joined
Jan 30, 2004
Messages
6
Hello, I am working in MSAccess 2003 and am creating a database for physicians to enter patient data. My first form contains general patient info. From the Patient Information form, you click a button that opens the Patient Follow Up form which allows the physician to enter followup data on how the patient responded to treatment. The Patient Follow Up form displays the Patient ID number (carried through from the Patient Info form) and then a combo box where you select the available Follow Up Date (patients have multiple follow up visits).
My problem: When I click the button to go to Patient FollowUp the form displays the data for the correct Patient BEFORE I select a Follow Up from the Combo box. I don't want the form to populate with any data (other than patient ID) until the physician selects the appropriate follow up date.
Based on a related thread in this message board from Corticus, I made the Patient Follow Up form based on a qyr (not a table) and then tried to add code to the FollowUpDateSelected combo box:
_________________________________

FollowUpDateSelected_afterupdate()

If Not Isnull(FollowUpDateSelected) Then
If Me.Dirty then Me.Dirty = False
End if

Me.Requery

End Sub
________________________

I also tried:
___________________________
FollowUpDateSelcted_Afterupdate()

If Me.Dirty = True then Me.Dirty = False
Forms.frmPatientFollowUp.FollowUpDatSelected.requery

end sub
_______________________

In both instances, when I clicked from the Patient Info to the Patient FollowUp form, the form was completely blank and I lost the Patient ID link from Patient Info. Consequently, when I change the Patient Follow Up form data source back to the tblFollowUP, the form opens as it was before. I also tried messing with a "Filter" property but that doesn't seem to work as it requires the FollowUp date be entered before my form opens.
This message board has been so helpful. I really appreciate suggestions anyone has. Thank you!
 

Excel Facts

How to calculate loan payments in Excel?
Use the PMT function: =PMT(5%/12,60,-25000) is for a $25,000 loan, 5% annual interest, 60 month loan.
Hi NRP,

The problem is, the follow-up form is bound to the query you created, so as long as that query returns some records, the form is going to display one of them. The other problem is that if the query returns no records (rs.eof), then the form comes up completely blank. Strangely Access 97 seems to have dealt with this better and at least has the form pop up with empty controls instead of loading completely blank like 2000 (and 2003 i assume).

I've always dealt with this problem by setting the form's recordsource to "", along with the controlsources of all the bound controls on the form.
You then set the forms recordsource to the required query once the follow-up choice on this form has been made. You can view the query as SQL, and then set it in code as a string. You will also have to go through the controls and set their control source to the appropriate fields of the query. This is tedious but effective.
 
Upvote 0
Thank you Corticus! You are right, very tedious as I have several other forms that need to be filtered as well. I really appreciate your assistance.
 
Upvote 0

Forum statistics

Threads
1,221,618
Messages
6,160,873
Members
451,674
Latest member
TJPsmt

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top