Please help!!! Run-time error 3828 Cannot reference a table with a multi-valued field ...

Copper Contributor

I have a form that passes a string to a query.  From the form, I want to convert the query results to a csv file.  I have checked several posts on this subject and they don't seem to have any problems using the DoCmd statement...I am posting my code below.

 

 

Private Sub Toggle15_Click()

Dim QueryName As String
Dim ReportName As String
Dim SaveLocation As String
Dim DateFormater As String
Dim FileNameFormat As String
Dim Project As String
Dim Location As String

 

QueryName = "qryConvert"
DateFormater = Format(Date, "MMDDYY")
ReportName = "ICAM Sustainment"
FileNameFormat = ReportName & " " & DateFormater & ".csv"

Project = DLookup("ProjectDescription", "tbl_Project", "PID =" & ProjectDescription)
Location = DLookup("Location", "tbl_Location", "LID =" & SiteLocation)
DoCmd.OpenQuery QueryName, acViewNormal, acEdit
DoCmd.TransferText acExportDelim, , QueryName, Text24 & "\" & Location & "_" & Project & FileNameFormat, True

MsgBox "Export is Complete!"

End Sub

 

I can't seem to find out what in the query is the problem.  I have a simple query with a lookup function for one value that is passed from a form...to select the records...The pic below shows where the code stops and the error message I get....Run-time error 3828 Cannot reference a table with a multi-valued field using an IN clause that refers to another database.

 

bbalzer_2-1613495893163.png

 

 

bbalzer_1-1613495581300.png

 

thanks in advance.....

 

43 Replies

@bbalzer I'm just sorry it took so long to get to the solution. But congratulations on solving it.

One of two possibilities come to mind, but neither seems likely to me without actually having the relational database application to analyze.

One is that the actual query was somehow corrupted. That can happen, rarely, but it can.

The other is that passing the reference the way the code was doing somehow was getting the reference wrong.

Continued success with the project.

My suggestion is to get rid of the multi-valued fields. Define your tables (and fields) the classical way, and create queries that refer to all the tables directly. That should eliminate the error.
Stacy, I suggest you read the ENTIRE thread. We ran way past that stage long ago. The problem, and the solution, were unrelated to MVFs, although that was my initial assumption as well.