Choose which subform to display from combo box? (1 Viewer)

Garindan

Registered User.
Local time
Today, 10:20
Joined
May 25, 2004
Messages
250
Sorry about this one, I know it's simple but I've not used Access for a while and my brain's not working :bang head:

I have a blank form with a subform. All I want to do is have a combo box with the names of the subforms in, and when you choose one it is displayed in the subform box.

Names of the subforms are:-

qselDuplicateCustomersByHomePhoneNumber
qselDuplicateCustomersByMobileNumber
qselDuplicateCustomersBySurname&Street
qselDuplicateCustomersBySurnameHouseNo&PartStreet
qselDuplicateCustomersBySurnameHouseNo&Street

I'd like to display them more readable in the combo box, i.e. 'Duplicate Customers by Mobile Number'.

I'd also prefer that the subform box is blank when the form is opened.

Many thanks for any help!!
 

Garindan

Registered User.
Local time
Today, 10:20
Joined
May 25, 2004
Messages
250
Thanks for that! But I actually haven't explained myself very well! Sorry!

I don't need to select a form to display in the subform box... I have a fixed subform, and what I actually need is for the combo box to change the record source of the subform!

Sorry about that! Like I said, my brain wasn't working.

So the combo box is cboSelectDuplicateQuery and the subform is fsubCustomerDuplicatesDetails

The combo box lists the names of 5 select queries. I just need to tell the subform record source to be the one selected in the combo box.

Any idea's? Sorry again!
 

bob fitz

AWF VIP
Local time
Today, 10:20
Joined
May 23, 2011
Messages
4,726
Perhaps something like:
Me!fsubCustomerDuplicatesDetails.Form.RecordSource = "cboSelectDuplicateQuery"
in the After Update event of the combo box.
 

BlueIshDan

☠
Local time
Today, 06:20
Joined
May 15, 2014
Messages
1,122
Perhaps something like:
Me!fsubCustomerDuplicatesDetails.Form.RecordSource = "cboSelectDuplicateQuery"
in the After Update event of the combo box.

Exactly, I'm sure they can replace a couple lines of code in the sample db to make this take affect. Thanks :)
 

Garindan

Registered User.
Local time
Today, 10:20
Joined
May 25, 2004
Messages
250
Thanks a lot guys!

I have both:-

Code:
Private Sub cboSelectDuplicateQuery_AfterUpdate()

Me!fsubCustomerDuplicatesDetails.Form.RecordSource = cboSelectDuplicateQuery.Value

End Sub

and

Code:
Private Sub cboSelectDuplicateQuery_Change()
    If Len(cboSelectDuplicateQuery.Value & vbNullString) > 0 Then
        Me!fsubCustomerDuplicatesDetails.Form.RecordSource = cboSelectDuplicateQuery.Value
        DoEvents
    End If
End Sub

Either work. Which is better? Thanks :)
 

BlueIshDan

☠
Local time
Today, 06:20
Joined
May 15, 2014
Messages
1,122
second one has code that checks to see if a value is actually selected
for which event to use, well I guess that's up to you.
 

Users who are viewing this thread

Top Bottom