need guidance on where to paste extended code

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

Guest

Working from the code suggested in the MSOffice Online article "Basing one
combo box on another"
(http://office.microsoft.com/en-us/assistance/HA011730581033.aspx) I have
this piece of code which displays an initial value in a combobox on a main
form:

Private Sub Form_Load()
If IsNull(cboPrimaryID) Then
Me.cboPrimaryID = Me.cboPrimaryID.ItemData(0)
End If
End Sub

But I also want similar behaviour in a combobox on a subform. I think the
code to do this should probably be:

Private Sub Form_Load()
If IsNull(Me!sfrOrderDtls.Form!cboCatalogID) Then
Me!sfrOrderDtls.Form!cboCatalogID =
Me!sfrOrderDtls.Form!cboCatalogID.ItemData(0)
End If
End Sub

What I don't know is just where to put this second piece of code. Exactly
where should I add it (all of it? - all except the first and last lines?) to
the first piece of code so that the main form's OnLoad event will perform
both the actions?
 
I would paste the following into the subform's Load event.

Private Sub Form_Load()
If IsNull(Me!cboCatalogID) Then
Me!cboCatalogID =
Me!cboCatalogID.ItemData(0)
End If
End Sub
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top