On my form_load I want set the RecordSource of a subform1 based on the CAN number (in the main form). After that I want to set the RecordSource of subform2 based on the CC Code from subform1. I would like utilize this same code after a CAN update. Any help would be appreciated.
Thank You,
rjoshi
my code:
Private Sub Form_Load()
Dim getdata As String
Dim candata As String
Dim costdata As String
MsgBox ("Hello: " & CurrentUser & "!"
'data for current form
getdata = "Select * from FY03COMREG where " & _
"FY03COMREG.[User ID] = '" & CurrentUser & "'"
Me.RecordSource = getdata
Me.Requery
'data for subform frmSubCanTable
'compare the value of CAN (current form/FY03COMREG table)
'with value of CAN in the master CAN table
candata = "SELECT * FROM FY03COMREG, [FY03 CAN Master Table]" & _
"WHERE (((FY03COMREG.CAN)=[FY03 CAN Master Table].[CAN]));"
Me.RecordSource = candata
Me.Requery
'data for subfrom frmSubCostCenter
'compare the value of cc code (frmSubCanTable/master CAN table)
'with value of cc code in the cost center table
costdata = "SELECT * FROM [Cost Center], [FY03 CAN Master Table]" & _
"WHERE [FY03 CAN Master Table].[CC Code]=[Cost Center].[CC Code];"
Me.RecordSource = costdata
Me.Requery
End Sub
Thank You,
rjoshi
my code:
Private Sub Form_Load()
Dim getdata As String
Dim candata As String
Dim costdata As String
MsgBox ("Hello: " & CurrentUser & "!"
'data for current form
getdata = "Select * from FY03COMREG where " & _
"FY03COMREG.[User ID] = '" & CurrentUser & "'"
Me.RecordSource = getdata
Me.Requery
'data for subform frmSubCanTable
'compare the value of CAN (current form/FY03COMREG table)
'with value of CAN in the master CAN table
candata = "SELECT * FROM FY03COMREG, [FY03 CAN Master Table]" & _
"WHERE (((FY03COMREG.CAN)=[FY03 CAN Master Table].[CAN]));"
Me.RecordSource = candata
Me.Requery
'data for subfrom frmSubCostCenter
'compare the value of cc code (frmSubCanTable/master CAN table)
'with value of cc code in the cost center table
costdata = "SELECT * FROM [Cost Center], [FY03 CAN Master Table]" & _
"WHERE [FY03 CAN Master Table].[CC Code]=[Cost Center].[CC Code];"
Me.RecordSource = costdata
Me.Requery
End Sub