T
TonyWilliams via AccessMonster.com
I have some code that opens a form. If the code is based on one table and
form it works fine. If I try to run the same code against another table with
only the table and destination form names changed the form opens but doesn't
show any records. Could someone help me where to start looking please. Below
(for those who want to read it!) is the two sets of code:
Thanks for anyone who can help, I was hoping to get this to bed befiore
Christmas :-(
Tony
This DOESN'T work:
Private Sub Command35_Click()
On Error GoTo Err_Command35_Click
Dim strsql As String
Dim strtxtcompany As String
Dim dattxtdate As Date
dattxtdate = Me.txtmontha
strtxtcompany = Me.cmbselectcompany
strsql = "SELECT * FROM [tblmainIrish] " & _
"WHERE [txtmonthlabel] = #" & Format(dattxtdate, "mmmm/yyyy") & "#" & _
"AND [txtmonthlabel] = #" & Format(dattxtdate, "mmmm/yyyy") & "#" & _
"AND [txtcompany] = '" & strtxtcompany & "'"
Forms!frmMain!SubForm1.SourceObject = "subformIrish"
Forms!frmMain!SubForm1.Form.RecordSource = strsql
Debug.Print strsql
Exit_Command35_Click:
Exit Sub
Err_Command35_Click:
MsgBox Err.Description
Resume Exit_Command35_Click
End Sub
This DOESN'T work:
Private Sub Command35_Click()
On Error GoTo Err_Command35_Click
Dim strsql As String
Dim strtxtcompany As String
Dim dattxtdate As Date
dattxtdate = Me.txtmontha
strtxtcompany = Me.cmbselectcompany
strsql = "SELECT * FROM [tblmaintabs] " & _
"WHERE [txtmonthlabel] = #" & Format(dattxtdate, "mmmm/yyyy") & "#" & _
"AND [txtmonthlabel] = #" & Format(dattxtdate, "mmmm/yyyy") & "#" & _
"AND [txtcompany] = '" & strtxtcompany & "'"
Forms!frmMain!SubForm1.SourceObject = "subformFDA"
Forms!frmMain!SubForm1.Form.RecordSource = strsql
Debug.Print strsql
Exit_Command35_Click:
Exit Sub
Err_Command35_Click:
MsgBox Err.Description
Resume Exit_Command35_Click
End Sub
form it works fine. If I try to run the same code against another table with
only the table and destination form names changed the form opens but doesn't
show any records. Could someone help me where to start looking please. Below
(for those who want to read it!) is the two sets of code:
Thanks for anyone who can help, I was hoping to get this to bed befiore
Christmas :-(
Tony
This DOESN'T work:
Private Sub Command35_Click()
On Error GoTo Err_Command35_Click
Dim strsql As String
Dim strtxtcompany As String
Dim dattxtdate As Date
dattxtdate = Me.txtmontha
strtxtcompany = Me.cmbselectcompany
strsql = "SELECT * FROM [tblmainIrish] " & _
"WHERE [txtmonthlabel] = #" & Format(dattxtdate, "mmmm/yyyy") & "#" & _
"AND [txtmonthlabel] = #" & Format(dattxtdate, "mmmm/yyyy") & "#" & _
"AND [txtcompany] = '" & strtxtcompany & "'"
Forms!frmMain!SubForm1.SourceObject = "subformIrish"
Forms!frmMain!SubForm1.Form.RecordSource = strsql
Debug.Print strsql
Exit_Command35_Click:
Exit Sub
Err_Command35_Click:
MsgBox Err.Description
Resume Exit_Command35_Click
End Sub
This DOESN'T work:
Private Sub Command35_Click()
On Error GoTo Err_Command35_Click
Dim strsql As String
Dim strtxtcompany As String
Dim dattxtdate As Date
dattxtdate = Me.txtmontha
strtxtcompany = Me.cmbselectcompany
strsql = "SELECT * FROM [tblmaintabs] " & _
"WHERE [txtmonthlabel] = #" & Format(dattxtdate, "mmmm/yyyy") & "#" & _
"AND [txtmonthlabel] = #" & Format(dattxtdate, "mmmm/yyyy") & "#" & _
"AND [txtcompany] = '" & strtxtcompany & "'"
Forms!frmMain!SubForm1.SourceObject = "subformFDA"
Forms!frmMain!SubForm1.Form.RecordSource = strsql
Debug.Print strsql
Exit_Command35_Click:
Exit Sub
Err_Command35_Click:
MsgBox Err.Description
Resume Exit_Command35_Click
End Sub