hi, problems with combo box and open form

  • Thread starter reservedbcreater
  • Start date
R

reservedbcreater

i want the user to select which form he wants to go to from a combo box
(the items in the combo box are the form names) and then the user clicks
Go Button(command2_click) and it goes to form they selected in the combo
box and closes current form........my code works but wont close the
current form with the combo box on it. If i put DoCMd.CLose in it it
gives me error that object doesnt exist when i click go.

If Not IsNull(cboreserve) Then
DoCMd.CLose <-------
DoCmd.OpenForm cboreserve

this is my code:

Private Sub Command2_Click()
On Error GoTo Err_Command2_Click


If Not IsNull(cboreserve) Then
DoCmd.OpenForm cboreserve

End If
Exit_Command2_Click:
Exit Sub

Err_Command2_Click:
MsgBox Err.Description
Resume Exit_Command2_Click

End Sub
 
S

Steve Conway

reservedbcreater said:
i want the user to select which form he wants to go to from a combo box
(the items in the combo box are the form names) and then the user clicks
Go Button(command2_click) and it goes to form they selected in the combo
box and closes current form........my code works but wont close the
current form with the combo box on it. If i put DoCMd.CLose in it it
gives me error that object doesnt exist when i click go.

If Not IsNull(cboreserve) Then
DoCMd.CLose <-------
DoCmd.OpenForm cboreserve

this is my code:

Private Sub Command2_Click()
On Error GoTo Err_Command2_Click


If Not IsNull(cboreserve) Then
DoCmd.OpenForm cboreserve

End If
Exit_Command2_Click:
Exit Sub

Err_Command2_Click:
MsgBox Err.Description
Resume Exit_Command2_Click

End Sub

You should be able to use

If Not IsNull(cboreserve) Then
DoCmd.OpenForm cboreserve
DoCmd.Close acForm, Me.Name
End If

you could also eliminate your Go button and just put the code in
cboreserve's After Update event

HTH
Steve C
 

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

Similar Threads

open in datasheet view 1
Create dir based on record ID 1
Error 2585 1
Opening form to new record 1
Do a Cmd & then Close 3
Opening forms with same ID no 2
compile error 2
Query based on dropdown selection 2

Top