Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Wanet Telecoms Ltd on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Updating a subform 1

Status
Not open for further replies.

stacy0966

Programmer
Apr 27, 2004
35
US
Hello,

I have a main form called customers and a subform called Hotel Arrangements. The main form stores names and addresses. It also has four check boxes (smoking, non-smoking, king, double). I click the check box to designate the type of hotel room the customer prefers. The main form has a button that will take you to the subform Hotel Arrangements. When a hotel reservation is entered on the subform it pull the room information from the main form (I.E. smoking, nonsmoking, king, double). This all works fine. My problem is if I add a new customer on the main form and use the button to go to the subform the hotel info. does not update. If I add a new customer to the main form and close the main form and open the subform everything works fine. Again, the problem is when I use the command button to go to the subform. Any ideas would be greatly appreciated.

Stacy
 
Can you post the code behind the Subform launch button?
 
Hi Mikelev,

Actually, when I click on the command button to go to the subform I have another button on the subform that I click to pull the hotel info. from the main form. It's at this point that the hotel info. is not be populated on the subform.
Thanks for the help.

Stacy
 
The code behind the command button is:

Private Sub Command59_Click()
On Error GoTo Err_Command59_Click

Dim stDocName As String
Dim stLinkCriteria As String

stDocName = "Customer Employee Table4"
DoCmd.OpenForm stDocName, , , stLinkCriteria

Exit_Command59_Click:
Exit Sub

Err_Command59_Click:
MsgBox Err.Description
Resume Exit_Command59_Click

End Sub


The code behind the check box on the subform is:

Private Sub DefaultSetupInfo_Click()

If DefaultSetupInfo = True And King = False And DoubleBed = False And Smoking = False And NonSmoking = False Then

King = [Forms]![Customer Employee Table4]![King]
DoubleBed = [Forms]![Customer Employee Table4]![DoubleBed]
Smoking = [Forms]![Customer Employee Table4]![Smoking]
NonSmoking = [Forms]![Customer Employee Table4]![NonSmoking]
End If

I thought there might be some way to refresh the subform?

Thanks,

Stacy


END SUB
 
Which piece of code should I put this on?

Thanks,

Stacy
 
King = [Forms]![Customer Employee Table4]!
DoubleBed = [Forms]![Customer Employee Table4]![DoubleBed]
Smoking = [Forms]![Customer Employee Table4]![Smoking]
NonSmoking = [Forms]![Customer Employee Table4]![NonSmoking]
docmd.Requery "yoursubform"

Replace "yoursubform" with the name of your form
 
I tried docmd.requery([Hotel Arrangements]) but got this error:
Microsoft Access can't find the field '|' referred to in your expression. Hotel Arrangements is the subform name. If all else fails I can put docmd.close on the command button.
Please let me know what you think.

Thanks again for your help.

Stacy
 
Hello,

I tried docmd.requery on the code behind the command button and it worked.

Stacy
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top