G
Guest
I have a form which I would like to load with different record sources,
depending upon which button is pressed on another form.
I can get this to work with a simple application, but a more complex one
with an IF statement, seems not to work.
If I embed the record source in the form ‘frmCensusResidents’ properties and
remove line 7, the procedure below works fine, but when I remove the data
source from the form and run the procedure with line X inserted, the form
loads without a record source. What is happening please?
Also, I have tried to insert the txtCensusDate value in the 'stLinkCriteria'
parameter of line 6, but that doesn't work either. Suggestions welcome!
1 Dim stDocName As String
2 Dim stLinkCriteria As String
3 Dim msg, response
3 stDocName = "frmCensusResidents"
4 If (FortyOne) = -1 Then
5 txtCensusDate = #6/6/1841#
6 DoCmd.OpenForm stDocName, , , stLinkCriteria
7 Forms! frmCensusResidents.RecordSource = qryCensusWomanResidents
8 DoCmd.MoveSize 0, 0, 14700, 8050
9 Else
10 msg = "No census data available"
11 response = msgbox(msg)
12 End If
depending upon which button is pressed on another form.
I can get this to work with a simple application, but a more complex one
with an IF statement, seems not to work.
If I embed the record source in the form ‘frmCensusResidents’ properties and
remove line 7, the procedure below works fine, but when I remove the data
source from the form and run the procedure with line X inserted, the form
loads without a record source. What is happening please?
Also, I have tried to insert the txtCensusDate value in the 'stLinkCriteria'
parameter of line 6, but that doesn't work either. Suggestions welcome!
1 Dim stDocName As String
2 Dim stLinkCriteria As String
3 Dim msg, response
3 stDocName = "frmCensusResidents"
4 If (FortyOne) = -1 Then
5 txtCensusDate = #6/6/1841#
6 DoCmd.OpenForm stDocName, , , stLinkCriteria
7 Forms! frmCensusResidents.RecordSource = qryCensusWomanResidents
8 DoCmd.MoveSize 0, 0, 14700, 8050
9 Else
10 msg = "No census data available"
11 response = msgbox(msg)
12 End If