CrystalVis
Technical User
i'm using Acess 2003 front end and backend is SQL Server 2000. i created a blank database and link it to SQL Server via ODBC. i'm trying to create form so the user can search/update/add record to a table. on the form header, i have a combo box base on the task table, once the user select a task code in the combo box, the code run and query the task table for a record match the task code selected in the combo box. if the query find a match, i want to display that record in the detail section. the combo box is working fine. however, when i click on the search button, i receive the following mesage: "Compile error: Invalid use of property". Below is the code behind the command search. i'm very new to Access and VBA. Any help/suggestion is greatly appreciated.
Private Sub cmdSearch_Click()
On Error GoTo Err_cmdSearch_Click
Dim strMsg As String
Dim strSQL As String
If Len(Me!CboTaskCode) > 0 Then
strSQL = "SELECT * FROM dbo_tblTasks WHERE TaskCode = '" & Me!CboTaskCode & "'"
'Assign RecordSource and display Detail section
Set Me.RecordSource = strSQL
'Call DisplayDetail(True)
Else
strMsg = "Please select a valid Task Code"
'Hide Detail Section
'Call DisplayDetail(False)
End If
If Len(strMsg) > 0 Then
MsgBox strMsg, , "Can't Display Task"
Me!CboTaskCode.SetFocus
'Call DisplayDetail(False)
End If
'resize form
DoCmd.RunCommand acCmdSizeToFitForm
'Screen.PreviousControl.SetFocus
'DoCmd.DoMenuItem acFormBar, acEditMenu, 10, , acMenuVer70
Exit_cmdSearch_Click:
Exit Sub
Err_cmdSearch_Click:
MsgBox Err.Description
Resume Exit_cmdSearch_Click
End Sub
Private Sub cmdSearch_Click()
On Error GoTo Err_cmdSearch_Click
Dim strMsg As String
Dim strSQL As String
If Len(Me!CboTaskCode) > 0 Then
strSQL = "SELECT * FROM dbo_tblTasks WHERE TaskCode = '" & Me!CboTaskCode & "'"
'Assign RecordSource and display Detail section
Set Me.RecordSource = strSQL
'Call DisplayDetail(True)
Else
strMsg = "Please select a valid Task Code"
'Hide Detail Section
'Call DisplayDetail(False)
End If
If Len(strMsg) > 0 Then
MsgBox strMsg, , "Can't Display Task"
Me!CboTaskCode.SetFocus
'Call DisplayDetail(False)
End If
'resize form
DoCmd.RunCommand acCmdSizeToFitForm
'Screen.PreviousControl.SetFocus
'DoCmd.DoMenuItem acFormBar, acEditMenu, 10, , acMenuVer70
Exit_cmdSearch_Click:
Exit Sub
Err_cmdSearch_Click:
MsgBox Err.Description
Resume Exit_cmdSearch_Click
End Sub