MS Access ODBC Call Failed Error (1 Viewer)

sonzy

New member
Local time
Today, 17:12
Joined
Sep 25, 2018
Messages
5
Hi All,

I have a database which is Access FE and SQL Server BE. I am trying to input data into a form and get an MS Access Run-time 3146 ODBC Call Failed Error. The debugger points me to the below, highlighting the 'DoCmd.OpenForm' part.

Private Sub cboDelegate_DblClick(Cancel As Integer)
Dim strSQL As String
strSQL = "SELECT * FROM qryDelegates WHERE SYS_ID = '" & Me.cboDelegate & "'"
DoCmd.OpenForm "frmDelegate", , strSQL
End Sub

Can anyone help solve this, I am a complete VBA newbie and have been stuck on this one for a while. Thanks :)
 

isladogs

MVP / VIP
Local time
Today, 17:12
Joined
Jan 14, 2017
Messages
18,207
Welcome to AWF

Set the control source for the form to qryDelegates.
Scrap the strsql line and assuming Sys_ID is a text field modify the following line to
Code:
DoCmd.OpenForm "frmDelegate", , , "SYS_ID = '" & Me.cboDelegate & "'"

If SYS_ID is a number field, use "SYS_ID = " & Me.cboDelegate
 

Users who are viewing this thread

Top Bottom