This page is dedicated to share scale modeling and other hobbies to all other enthusiasts who also love these stuffs. Hope you enjoy and please feel free to give me some comments no matter good or bad. Joey

Monday, December 28, 2009

Ad hoc Assignment - Simple MS Access DB Form

Option Compare Database

'This function will run when the "All" button is clicked.
Private Sub DisplayAll_Click()
Form_CustomerList.RecordSource = "select CustomerList.TGAcctNo, CustomerList.FieldworkStartDate, CustomerList.FieldworkEndDate , SurveyInfo.* from CustomerList inner join SurveyInfo on SurveyInfo.SurveyID = CustomerList.SurveyID"
End Sub

'This function will run when the "Search" button is clicked.
Private Sub DisplaySearch_Click()
'Check text field
If Len(AcctSearch) = 0 Or IsNull(AcctSearch) Or Len(AcctSearch) < 10 = True Then
MsgBox "Please a valid TG Account No."
Else
'Update query
Form_CustomerList.RecordSource = "select CustomerList.TGAcctNo, CustomerList.FieldworkStartDate, CustomerList.FieldworkEndDate , SurveyInfo.* from CustomerList inner join SurveyInfo on SurveyInfo.SurveyID = CustomerList.SurveyID where CustomerList.TGAcctNo like '" & AcctSearch & "'"
MsgBox Form_CustomerList.RecordsetClone.RecordCount & " Record(s) found."
End If
End Sub

'This function will run when the form is first opened.
Private Sub Form_Open(Cancel As Integer)
Form_CustomerList.RecordSource = ""
'Form_CustomerList.RecordSource = "select CustomerList.TGAcctNo, CustomerList.FieldworkStartDate, CustomerList.FieldworkEndDate , SurveyInfo.* from CustomerList inner join SurveyInfo on SurveyInfo.SurveyID = CustomerList.SurveyID"
End Sub

No comments:

Post a Comment

 
free counters