Ambiguous Name Detected:Left

jlg5454

New Member
Joined
May 6, 2004
Messages
20
I experience this error in Access 2000 trying to construct a list box criteria search:

Ambiguous Name Detected:Left here is code:

Private Sub cmdOpenQuery_Click()

Dim blnQueryExists As Boolean
Dim cat As New ADOX.Catalog
Dim cmd As New ADODB.Command
Dim qry As ADOX.View
Dim varItem As Variant
Dim strteam As String
Dim strSQL As String
' Check for the existence of the stored query
blnQueryExists = False
Set cat.ActiveConnection = CurrentProject.Connection
For Each qry In cat.Views
If qry.Name = "Team3" Then
blnQueryExists = True
Exit For
End If
Next qry
' Create the query if it does not already exist
If blnQueryExists = False Then
cmd.CommandText = "SELECT * FROM Service Sells"
cat.Views.Append "Team3", cmd
End If
Application.RefreshDatabaseWindow
' Turn off screen updating
DoCmd.Echo False
' Close the query if it is already open
If SysCmd(acSysCmdGetObjectState, acQuery, "Team3") = acObjStateOpen Then
DoCmd.Close acQuery, "Team3"
End If
' Build criteria string for Office
For Each varItem In Me.lstteam.ItemsSelected
strteam = strteam & ",'" & Me.lstteam.ItemData(varItem) & "'"
Next varItem
If Len(strteam) = 0 Then
strteam = "Like '*'"
Else
strteam = Left(strteam, Len(strteam) - 1)
strteam = "IN(" & strteam & ")"
End If
' Build SQL statement
strSQL = "SELECT [Service Sells].[Team Namea], [Service Sells].[Last Name], [Service Sells].[First Name], [Service Sells].[66 General Deposit], [Service Sells].[34 Loans], [Service Sells].[84 Advisor Deposit], [Service Sells].[164 Retention Deposit]FROM [Service Sells];"
' Apply the SQL statement to the stored query
cat.ActiveConnection = CurrentProject.Connection
Set cmd = cat.Views("Team3").Command
cmd.CommandText = strSQL
Set cat.Views("Team3").Command = cmd
Set cat = Nothing
' Open the Query
DoCmd.OpenQuery "Team3"
' If required the dialog can be closed at this point
' DoCmd.Close acForm, Me.Name
' Restore screen updating
DoCmd.Echo True
End Sub
 

Excel Facts

Which came first: VisiCalc or Lotus 1-2-3?
Dan Bricklin and Bob Frankston debuted VisiCalc in 1979 as a Visible Calculator. Lotus 1-2-3 debuted in the early 1980's, from Mitch Kapor.
Just a stab in the dark! Have you used Left as a field name in the form anywhere?

Peter
 
Upvote 0
Out of curiosity, which references do you have selected (in the VB editor, go to Tools | References)?

You should at least have the following selected:
-Visual Basic for Applications
-Microsoft Access X.X Object Library (where X.X is a version number)
 
Upvote 0

Forum statistics

Threads
1,221,771
Messages
6,161,847
Members
451,723
Latest member
Rachetsely

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top