To both Albert and John,
Yes my combo box already has data in it, right now there are three choices.
Endmills
Drills
Reamers
When the user clicks Endmills, I want a form named EndmillsFRM to pop open.
The same is true for the other two choices. I would like the form to remain
open while the data is entered and then closed at the start of the next
record.
Thank you. That was not at all evident from your original post, and is quite a
different problem! Remember, you can see your computer - we cannot!
How are these three forms different? Do you have separate forms, separate
tables, separate queries for the three kinds of tools? If so, I suspect your
table structure needs attention. But if it's legitimate, you'll need code
like:
Private Sub comboboxname_AfterUpdate()
Dim strForm As String
Select Case Me!comboboxname
Case "Endmills"
strForm = "FRMEndmills"
Case "Drills"
strForm = "FRMDrills"
Case "Reamers"
strForm = "FRMReamers"
Case Else
Msgbox "Please choose a tool type"
strForm = ""
End Select
If strForm <> "" Then
DoCmd.OpenForm strForm, DataMode := acFormAdd, WindowMode := acDialog
End If
End Sub
You'll also need to add code in each form's AfterUpdate event to close the
form.
You *could* use code instead of the Select Case... End Select like
strForm = "FRM" & Me!comboboxname
but that would constrain your choice of form names and could cause problems
(say if you need an altered form with a different name for testing). Or you
could use a two column combo box with the actual form name in the bound (but
concealed) column.
Just an oddity note: in the summer of 1965 my first wage-paying job was
working at a company using diamond grinding wheels to finish tungsten carbide
endmills, drills and reamers to 0.0002" or better tolerance...