I've been working with Access a few (short) years, and designs are getting more and more complicated now. I have an issue that I can't work out of, and I can't seem to find the exact solution in any of the other threads so I'm posting it here.
I’m creating a db for a local painter who wants to track his paintings, customers and so on.
I have a main form (fmPaintings) with a sub-form (sfPaintingsSold) on it. This sub-form is for display only, no information can be entered here. fmPaintings is to display the information about a painting, sfPaintingsSold if the painting was sold. The information from the sub-form comes from a separate table (this table is needed because it’s used somewhere else). On the main form I have a button to open an external form (fmSellPaintings) to enter when and to whom the painting was sold. Clicking the button brings up the correct form with the name of the painting already entered. After entering the information and closing the form, I would like to have a re-query of the main form to update the information on the sub-form.
This is my code:
Private Sub Sell_Click()
On Error GoTo Err_Sell_Click
Dim stDocName As String
Dim strPrev As String
strPrev = Me.PaintingID
stDocName = "fmSellPaintings"
DoCmd.OpenForm stDocName, , , , acFormAdd, , Me.PaintingID
Me.Requery
Me.Recordset.FindFirst "PaintingID = '" & strPrev & "'"
Exit_Sell_Click:
Exit Sub
Err_Sell_Click:
MsgBox Err.Description
Resume Exit_Sell_Click
This doesn’t work. Even after entering information on the fmSellPaintings screen, the fmPaintings form still gives me no data in the subform. I’ve also tried a requery on the subform. I have noticed that the moment the sub-form opens, the requery is done, so I guess I would need to postpone that until after I come back to the main form.
I also have a search button to enter a file name into a text box (Photo) that has the following (partial) code:
strInputFileName = ahtCommonFileOpenSave( _
Filter:=strFilter, OpenFile:=True, _
DialogTitle:="Please select an input file...", _
Flags:=ahtOFN_HIDEREADONLY)
Me.Photo = strInputFileName
Me.Requery
Me.Recordset.FindFirst "PaintingID = '" & strPrev & "'"
This works. What is the difference here, and how can I make the first part work?
I hope I made my dilemma clear and I appreciate any answers that will help me resolve this.
Thanks so much!
Michel