Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Making A Search Form

Status
Not open for further replies.

RamziSaab

MIS
May 7, 2003
522
0
0
GB
i need to make a searhch form that allows user to pick from a list of tables (or queries)... then allows him to pick the fiels in that table or query and enter criteria for what he wants to see.

basically like building a query but using a form.
Ramzi
 
Hi

To begin, look at the system tables, from there you can get the list of available tables, and the list of available columns, with which to populate your combo boxes

Regards

Ken Reay
Freelance Solutions Developer
Boldon Information Systems Ltd
Website needs upgrading, but for now - UK
 
yeah i know how to get a list of tables, queries reports ect. in a combo box, and how to get a field list. But how do u make that field list from the first combo box?
 
Look at one of my threads. I think you have the same question I had, and this thread helped me. Look toward the bottom of the thread:

thread702-517598

Good Luck,

Jerome Benton
JERPAT Web Designs
GOD Is Good All The Time!!!
 
Post your email address and I will send you a form that will do the job.

What version of MS Access do you use?

Ed Metcalfe.

Please do not feed the trolls.....
 
Hey thanks for the replies...but i finally managed to sort it out...My form lets u pick upto six tables (you can choose how many) lets u pick any fields you want, up two criteria from the first table you chose and lets you build two expressions...all optional...it works great...though considering i have no prior vba experience i am sure there is a lot of junk in the code...anyone want to have a look...

 
I'd like a look please:

ed_metcalfe_work@hotmail.com

Please do not feed the trolls.....
 
I would like this also

my email

sandy.dickson@fluor.com

I'm working on a project similar to this today and need this badly...thanks
 
Ok bored of emailing it to people so i will post it...
Anyone who knows anything about programming and can clean it up will be happy for your input otherwise hope its useful to you. Its not generic and only works for tables with ID as a key...

I started this code from downloaded generic query builders from this site ...the code i used at the begining (which i based my stuff on) is from this site to (all credit to him)
Its 8 pages long

GOod luck
RAmzi


Sub cmdRunReport_Click()
On Error GoTo Err_cmdRunReport_Click
Dim MyDB As DAO.Database
Dim qdf As DAO.QueryDef
Dim rcdErrRecSet As DAO.Recordset
Dim rst As DAO.Recordset, rst2 As DAO.Recordset, rstk As DAO.Recordset, rstl As DAO.Recordset, rstm As DAO.Recordset, rstn As DAO.Recordset, _
rstp As DAO.Recordset, rsto As DAO.Recordset
Dim i As Integer, j As Integer, k As Integer, x As Integer, y As Integer, z As Integer, n As Integer, m As Integer
Dim strSQL As String
Dim strFieldList As String, strIN As String
Dim strFieldListk As String, strINk As String, strWhereIN As String, strWhereKIN As String
Dim strINm As String, strINn As String, strIno As String, strinp As String
Dim flgAll As Boolean
Dim strWhere As String
Dim strWherek As String
Set MyDB = CurrentDb()
Dim strOpLinel As String
Dim strOplinek As String
Dim strOpLinem As String
Dim strOplinen As String
Dim strqueryname As String
Dim stroperation2 As String
Dim strSelect As String
Dim fld As DAO.Field
Dim strintotal As String
Dim strInnerjoin As String
Dim strSuggestName As String
Dim intmsgbox As Integer
Dim strOperation As String
Set rst = MyDB.OpenRecordset("usystablefields")
Set rstk = MyDB.OpenRecordset("usystablefieldsk")
Set rstl = MyDB.OpenRecordset("usystablefieldsL")
Set rstm = MyDB.OpenRecordset("usystablefieldsm")
Set rstn = MyDB.OpenRecordset("usystablefieldsn")
Set rsto = MyDB.OpenRecordset("usystablefieldso")
Set rstp = MyDB.OpenRecordset("usystablefieldsp")

strSQL = "SELECT "
' j = 0
' k = 0
' l = 0
' m = 0

'SQL STRING FROM TABLE ONE FROM THE FIRST LIST

rst.MoveFirst
'create the IN string by looping thru the listbox
For i = 0 To lstField.ListCount - 1
If lstField.Selected(i) Then
strIN = strIN & "[" & Me!cboTable & "]." & "[" & lstField.Column(0, i) & "] ,"
' rst.Edit
' rst!indexx = k
' rst.Update
rst.MoveNext
' k = k + 1
' Else
' rst.Edit
' rst!indexx = Null
' rst.Update
' rst.MoveNext
End If
' j = j + 1
Next i
'SQL STRING FROM TABLE TWO FROM THE SECOND LIST

If Me!cboTablek = " " Then
Else
rstk.MoveFirst
For x = 0 To lstFieldK.ListCount - 1
If lstFieldK.Selected(x) Then
strINk = strINk & "[" & Me!cboTablek & "]." & "[" & lstFieldK.Column(0, x) & "] ,"
' rstk.Edit
' rstk!indexx = k
' rstk.Update
rstk.MoveNext
' k = k + 1
Else
' rstk.Edit
' rstk!indexx = Null
' rstk.Update
' rstk.MoveNext
End If
' j = j + 1
Next x
' For x = k To lstFieldK.ListCount - 1
' strIN = strIN & "null as Field" & i & ","
' Next x
' stripoff the last comma of the IN string
'strFieldListk = Left(strINk, Len(strINk) - 1)
End If

' SELECTS FROM TABLE 3 AND ITS FIELDS

If Me!cboTableM = " " Then
Else
rstm.MoveFirst
For y = 0 To lstFieldM.ListCount - 1
If lstFieldM.Selected(y) Then
strINm = strINm & "[" & Me!cboTableM & "]." & "[" & lstFieldM.Column(0, y) & "] ,"
' rst.Edit
' rst!indexx = k
' rst.Update
rstm.MoveNext
' k = k + 1
Else
' rst.Edit
' rst!indexx = Null
' rst.Update
' rst.MoveNext
End If
' j = j + 1
Next y
' For Y = k To lstFieldm.ListCount - 1
' strINm = strINm & "null as Field" & i & ","
' Next x
' stripoff the last comma of the IN string
'strFieldListm = Left(strINm, Len(strINm) - 1)
End If
'MsgBox (strINm)


If Me!cboTableN = " " Then
Else
rstn.MoveFirst
For z = 0 To lstFieldN.ListCount - 1
If lstFieldN.Selected(z) Then
strINn = strINn & "[" & Me!cboTableN & "]." & "[" & lstFieldN.Column(0, z) & "] ,"
' rst.Edit
' rst!indexx = k
' rst.Update
rstn.MoveNext
' k = k + 1
Else
' rst.Edit
' rst!indexx = Null
' rst.Update
' rst.MoveNext
End If
' j = j + 1
Next z
' For x = k To lstFieldn.ListCount - 1
' strINn = strINn & "null as Field" & i & ","
' Next x
' stripoff the last comma of the IN string
'strFieldListn = Left(strINn, Len(strINn) - 1)
End If

If Me!cboTableO = " " Then
Else
rsto.MoveFirst
For z = 0 To lstFieldo.ListCount - 1
If lstFieldo.Selected(z) Then
strIno = strIno & "[" & Me!cboTableO & "]." & "[" & lstFieldo.Column(0, z) & "] ,"
' rst.Edit
' rst!indexx = k
' rst.Update
rsto.MoveNext
' k = k + 1
Else
' rst.Edit
' rst!indexx = Null
' rst.Update
' rst.MoveNext
End If
' j = j + 1
Next z
' For x = k To lstFieldo.ListCount - 1
' strINo = strINo & "null as Field" & i & ","
' Next x
' stripoff the last comma of the IN string
'strFieldListo = Left(strINo, Len(strINno) - 1)
End If

If Me!cboTableP = " " Then
Else
rstp.MoveFirst
For z = 0 To LstFieldP.ListCount - 1
If LstFieldP.Selected(z) Then
strinp = strinp & "[" & Me!cboTableP & "]." & "[" & LstFieldP.Column(0, z) & "] ,"
' rst.Edit
' rst!indexx = k
' rst.Update
rstp.MoveNext
' k = k + 1
Else
' rst.Edit
' rst!indexx = Null
' rst.Update
' rst.MoveNext
End If
' j = j + 1
Next z
' For x = k To lstFieldo.ListCount - 1
' strINp = strINp & "null as Field" & i & ","
' Next x
' stripoff the last comma of the IN string
'strFieldListp = Left(strINp, Len(strINnp) - 1)
End If


'This will write the SELECT bit for the SQL for the expression

strintotal = strIN & strINk & strINm & strINn & strIno & strinp

'MsgBox strintotal
'Next bif of the Select statements, Sees if you are using the expression builder

If Me!cbotablel = " " Then
strSelect = strIN & strINk & strINm & strINn & strIno & strinp
strintotal = Left(strSelect, Len(strSelect) - 1)
Else
strOpLinel = "[" & Me!cbotablel & "]." & "[" & cboAddFieldL & "]" & Me!cboOperationl & "[" & Me!cbotableq & "]." & "[" & Me!cboAddFieldq & "] As [" & cboAddFieldL & "" & Me!cboOperationl & "" _
& cboAddFieldq & "],"
strOplinek = "[" & Me!cbotablel & "]." & "[" & cboAddFieldL & "]" & Me!cboOperationl & "[" & Me!cbotableq & "]." & "[" & Me!cboAddFieldq & "]" _
& Me!cboOperationk & "[" & Me!cbotabler & "]." & "[" & cboAddFieldr & "] As [" & cboAddFieldL & "" & Me!cboOperationl & "" _
& cboAddFieldq & "" & Me!cboOperationk & "" & cboAddFieldr & "],"

If Me!cboOperationk = " " Then
strOperation = strOperation & strOpLinel
Else
strOperation = strOperation & strOplinek
'MsgBox strOperation
End If
End If

If Me!cbotableS = " " Then
strSelect = strIN & strINk & strINm & strINn & strIno & strinp & strOperation
strintotal = Left(strSelect, Len(strSelect) - 1)
strOperation = ""
Else
strOpLinem = "[" & Me!cbotableS & "]." & "[" & cboAddFieldS & "]" & Me!cbooperations & "[" & Me!cbotableT & "]." & "[" & Me!cboAddFieldT & "] As [" & cboAddFieldS & "" & Me!cbooperations & "" _
& cboAddFieldT & "]"
strOplinen = "[" & Me!cbotableS & "]." & "[" & cboAddFieldS & "]" & Me!cbooperations & "[" & Me!cbotableT & "]." & "[" & Me!cboAddFieldT & "]" _
& Me!cbooperationT & "[" & Me!cbotableU & "]." & "[" & cboAddFieldU & "] As [" & cboAddFieldS & "" & Me!cbooperations & "" _
& cboAddFieldT & "" & Me!cbooperationT & "" & cboAddFieldU & "] "

If Me!cbooperationT = " " Then
stroperation2 = stroperation2 & strOpLinem
Else
stroperation2 = stroperation2 & strOplinen
'MsgBox stroperation2
End If
End If
'Inner Join operation selects depending of how many tables are being used

If Me!cboTablek = " " Then
strInnerjoin = "[" & Me!cboTable & "]"
ElseIf Me!cboTableM = " " Then
strInnerjoin = "[" & Me!cboTable & "] INNER JOIN " & "[" & Me!cboTablek & "] on " & "[" & Me!cboTable & "].ID" & " = " & "[" & Me!cboTablek & "].ID"
ElseIf Me!cboTableN = " " Then
strInnerjoin = "([" & Me!cboTable & "] INNER JOIN " & "[" & Me!cboTablek & "] on " & "[" & Me!cboTable & "].ID" & " = " & "[" & Me!cboTablek & "].ID)" _
& " INNER JOIN " & "[" & Me!cboTableM & "] on " & "[" & Me!cboTable & "].ID" & " = " & "[" & Me!cboTableM & "].ID"
ElseIf Me!cboTableO = " " Then
strInnerjoin = "(([" & Me!cboTable & "] INNER JOIN " & "[" & Me!cboTablek & "] on " & "[" & Me!cboTable & "].ID" & " = " & "[" & Me!cboTablek & "].ID)" _
& " INNER JOIN " & "[" & Me!cboTableM & "] on " & "[" & Me!cboTable & "].ID" & " = " & "[" & Me!cboTableM & "].ID)" _
& " INNER JOIN " & "[" & Me!cboTableN & "] on " & "[" & Me!cboTable & "].ID" & " = " & "[" & Me!cboTableN & "].ID"
ElseIf Me!cboTableP = " " Then
strInnerjoin = "((([" & Me!cboTable & "] INNER JOIN " & "[" & Me!cboTablek & "] on " & "[" & Me!cboTable & "].ID" & " = " & "[" & Me!cboTablek & "].ID)" _
& " INNER JOIN " & "[" & Me!cboTableM & "] on " & "[" & Me!cboTable & "].ID" & " = " & "[" & Me!cboTableM & "].ID)" _
& " INNER JOIN " & "[" & Me!cboTableN & "] on " & "[" & Me!cboTable & "].ID" & " = " & "[" & Me!cboTableN & "].ID)" _
& " INNER JOIN " & "[" & Me!cboTable0 & "] on " & "[" & Me!cboTable & "].ID" & " = " & "[" & Me!cboTable0 & "].ID"
Else
strInnerjoin = "(((([" & Me!cboTable & "] INNER JOIN " & "[" & Me!cboTablek & "] on " & "[" & Me!cboTable & "].ID" & " = " & "[" & Me!cboTablek & "].ID)" _
& " INNER JOIN " & "[" & Me!cboTableM & "] on " & "[" & Me!cboTable & "].ID" & " = " & "[" & Me!cboTableM & "].ID)" _
& " INNER JOIN " & "[" & Me!cboTableN & "] on " & "[" & Me!cboTable & "].ID" & " = " & "[" & Me!cboTableN & "].ID)" _
& " INNER JOIN " & "[" & Me!cboTableO & "] on " & "[" & Me!cboTable & "].ID" & " = " & "[" & Me!cboTableO & "].ID)" _
& " INNER JOIN " & "[" & Me!cboTableP & "] on " & "[" & Me!cboTable & "].ID" & " = " & "[" & Me!cboTableP & "].ID"
End If

'MsgBox strInnerjoin
strSQL = strSQL & strintotal & strOperation & stroperation2 & "FROM " & strInnerjoin
' MsgBox strSQL



'create the WhereIN string by looping thru the listbox

If Me!cboFieldName = " " Then
strSQL = strSQL
Else
For i = 0 To lstCriteria.ListCount - 1
If lstCriteria.Selected(i) Then
If lstCriteria.Column(0, i) = "All" Then
flgAll = True
End If

' Check data type of field for delimiting
If cboFieldName.Column(1) >= 1 And cboFieldName.Column(1) <= 7 Then
' If the field holds numeric data
strWhereIN = strWhereIN & &quot; &quot; & lstCriteria.Column(0, i) & &quot;,&quot;
ElseIf cboFieldName.Column(1) = 8 Then
'field is date
strWhereIN = strWhereIN & &quot;#&quot; & lstCriteria.Column(0, i) & &quot;#,&quot;
ElseIf cboFieldName.Column(1) = 10 Then
'field is text
strWhereIN = strWhereIN & &quot;'&quot; & lstCriteria.Column(0, i) & &quot;',&quot;
End If
End If
Next i
'create the WHERE string, stripping off the last comma of the IN string
strWhere = &quot; WHERE [&quot; & Me!cboTable & &quot;].[&quot; & Me!cboFieldName & &quot;] in (&quot; & Left(strWhereIN, Len(strWhereIN) - 1) & &quot;)&quot;
' MsgBox strWhere
'if &quot;All&quot; was selected, don't add the WHERE condition
If Not flgAll Then
strSQL = strSQL & strWhere
End If
End If

If Me!cboFieldName2 = &quot; &quot; Then
Else
For i = 0 To kstCriteria.ListCount - 1
If kstCriteria.Selected(i) Then
If kstCriteria.Column(0, i) = &quot;All&quot; Then
flgAll = True
End If

' Check data type of field for delimiting
If cboFieldName2.Column(1) >= 1 And cboFieldName2.Column(1) <= 7 Then
' If the field holds numeric data
strWhereKIN = strWhereKIN & &quot; &quot; & kstCriteria.Column(0, i) & &quot;,&quot;
ElseIf cboFieldName2.Column(1) = 8 Then
'field is date
strWhereKIN = strWhereKIN & &quot;#&quot; & kstCriteria.Column(0, i) & &quot;#,&quot;
ElseIf cboFieldName2.Column(1) = 10 Then
'field is text
strWhereKIN = strWhereKIN & &quot;'&quot; & kstCriteria.Column(0, i) & &quot;',&quot;
End If
End If
Next i
'create the WHERE string, stripping off the last comma of the IN string
strWherek = &quot; AND [&quot; & Me!cboTable & &quot;].[&quot; & Me!cboFieldName2 & &quot;] in (&quot; & Left(strWhereKIN, Len(strWhereKIN) - 1) & &quot;)&quot;
'MsgBox strWhereK
'if &quot;All&quot; was selected, don't add the WHERE condition
If Not flgAll Then
strSQL = strSQL & strWherek
End If
End If

On Error Resume Next
strqueryname = [textval]
Select Case Err
Case 0
On Error GoTo 0 'No error
Case 94
On Error GoTo 0 'No error a name was typed in
If Me!cboTablek = &quot; &quot; Then
strSuggestName = &quot;qry Search &quot; & Me!cboTable
[textval] = strSuggestName
ElseIf Me!cboTableM = &quot; &quot; Then
strSuggestName = &quot;qry Search &quot; & Me!cboTable & &quot; &quot; & Me!cboTablek & &quot;&quot;
[textval] = strSuggestName
MsgBox &quot;You have not entered a name to save file. A default name (&quot; & strSuggestName & &quot;) has been entered for you&quot;
ElseIf Me!cboTableN = &quot; &quot; Then
strSuggestName = &quot;qry Search &quot; & Me!cboTable & &quot; to &quot; & Me!cboTableM & &quot;&quot;
[textval] = strSuggestName
MsgBox &quot;You have not entered a name to save file. A default name (&quot; & strSuggestName & &quot;) has been entered for you&quot;
ElseIf Me!cboTableO = &quot; &quot; Then
strSuggestName = &quot;qry Search &quot; & Me!cboTable & &quot; to &quot; & Me!cboTableN & &quot;&quot;
[textval] = strSuggestName
MsgBox &quot;You have not entered a name to save file. A default name (&quot; & strSuggestName & &quot;) has been entered for you&quot;
Else
strSuggestName = &quot;qry Search &quot; & Me!cboTable & &quot; to &quot; & Me!cboTableP & &quot;&quot;
[textval] = strSuggestName
MsgBox &quot;You have not entered a name to save file. A default name(&quot; & strSuggestName & &quot;) has been entered for you&quot;
End If


End Select

If [textval] = &quot;&quot; Then
If Me!cboTablek = &quot; &quot; Then
strSuggestName = &quot;qry Search &quot; & Me!cboTable
[textval] = strSuggestName
ElseIf Me!cboTableM = &quot; &quot; Then
strSuggestName = &quot;qry Search &quot; & Me!cboTable & &quot; &quot; & Me!cboTablek & &quot;&quot;
[textval] = strSuggestName
MsgBox &quot;You have not entered a name to save file. A default name (&quot; & strSuggestName & &quot;) has been entered for you&quot;
ElseIf Me!cboTableN = &quot; &quot; Then
strSuggestName = &quot;qry Search &quot; & Me!cboTable & &quot; to &quot; & Me!cboTableM & &quot;&quot;
[textval] = strSuggestName
MsgBox &quot;You have not entered a name to save file. A default name (&quot; & strSuggestName & &quot;) has been entered for you&quot;
ElseIf Me!cboTableO = &quot; &quot; Then
strSuggestName = &quot;qry Search &quot; & Me!cboTable & &quot; to &quot; & Me!cboTableN & &quot;&quot;
[textval] = strSuggestName
MsgBox &quot;You have not entered a name to save file. A default name (&quot; & strSuggestName & &quot;) has been entered for you&quot;
Else
strSuggestName = &quot;qry Search &quot; & Me!cboTable & &quot; to &quot; & Me!cboTableP & &quot;&quot;
[textval] = strSuggestName
MsgBox &quot;You have not entered a name to save file. A default name(&quot; & strSuggestName & &quot;) has been entered for you&quot;
End If
End If


strqueryname = [textval]
DoCmd.Close acQuery, strqueryname
On Error Resume Next
Set rcdErrRecSet = MyDB.OpenRecordset(strqueryname)
Select Case Err
Case 0
On Error GoTo 0 'No error Table--table must exist
On Error GoTo Err_cmdRunReport_Click
intmsgbox = MsgBox(&quot;The &quot; & strqueryname & &quot; already exists. Press 'YES' to OVERWRITE the query or 'NO' to save file as a different name?&quot;, 52)
If intmsgbox = 6 Then
MyDB.QueryDefs.Delete (strqueryname)
Set qdf = MyDB.CreateQueryDef(strqueryname, strSQL)
DoCmd.OpenQuery (strqueryname)
Else
rcdErrRecSet.Close
MsgBox &quot;Please Enter A New Name&quot;
[textval].SetFocus
End If

Case 3011, 3078
On Error GoTo 0 'Table does not exists so make one.
On Error GoTo Err_cmdRunReport_Click
Set qdf = MyDB.CreateQueryDef(strqueryname, strSQL)
DoCmd.OpenQuery (strqueryname)

Case 3062
On Error GoTo 0
On Error GoTo Err_cmdRunReport_Click
MsgBox &quot;You have entered the same expression (in the both expression builders). This creates a duplicate field names. Please change one of expressions. If this is not the case please find the query manually and delete it.&quot;
GoTo Exit_cmdRunReport_Click


Case 3061
On Error GoTo 0 'No error Table--table must exist
On Error GoTo Err_cmdRunReport_Click
intmsgbox = MsgBox(&quot;The &quot; & strqueryname & &quot; already exists. Press 'YES' to OVERWRITE the query or 'NO' to save file as a different name?&quot;, 52)
If intmsgbox = 6 Then
MyDB.QueryDefs.Delete (strqueryname)
Set qdf = MyDB.CreateQueryDef(strqueryname, strSQL)
DoCmd.OpenQuery (strqueryname)
Else
MsgBox &quot;Please Enter A New Name&quot;
[textval].SetFocus
End If
End Select


Exit_cmdRunReport_Click:
Exit Sub



Err_cmdRunReport_Click:
If Err.Number = 3265 Then '*** if the error is the query is missing
Resume Next '*** then skip the delete line and resume on the next line
ElseIf Err.Number = 5 Then
MsgBox &quot;You must make a selection! You have selected a table or field and not filled in the criteria. Please go back and check, alternatively press the RESET button to restart your search.&quot;, , &quot;Missing Criteria Error&quot;
Resume Exit_cmdRunReport_Click
ElseIf Err.Number = 3135 Then
MsgBox &quot;Unable to complete process. The probable cause of the error is that you have selected to tables that are the same. Please check that all tables chosen are different. If this is not the problem the tables probably do not have an ID field which is the primary key please set this to use this form. For further information about this please see help file provided with the Financials Data help file&quot;, , &quot; SQL Error in the Join Operation&quot;
Resume Exit_cmdRunReport_Click
ElseIf Err.Number = 3296 Then
MsgBox &quot;Unable to complete process. The probable cause of the error is that you have selected to tables that are the same. Please check that all tables chosen are different. If this is not the problem the tables probably do not have an ID field which is the primary key please set this to use this form. For further information about this please see help file provided with the Financials Data help file&quot;, , &quot; SQL Error in the Join Operation&quot;
Resume Exit_cmdRunReport_Click
ElseIf Err.Number = 3126 Then
MsgBox &quot;You have selected but not filled in one of fields in one of the query expressions. Please redo the query or fill it in with a valid field.&quot;
Resume Exit_cmdRunReport_Click
ElseIf Err.Number = 3125 Then
MsgBox &quot;Sorry the suggested name is too long or contains invalid characters, you will have to type in the name manually.&quot;, , &quot;Sorry Invalid Save Name File&quot;
[textval].SetFocus
Resume Exit_cmdRunReport_Click
Else
MsgBox Err.Description '*** write out the error and exit the sub
Resume Exit_cmdRunReport_Click
End If

End Sub
 
Ok bored of emailing it to people so i will post it...
Anyone who knows anything about programming and can clean it up will be happy for your input otherwise hope its useful to you. Its not generic and only works for tables with ID as a key...

I started this code from downloaded generic query builders from this site ...the code i used at the begining (which i based my stuff on) is from this site to (credit to him for his help).
Its 8 pages long

GOod luck
RAmzi


Sub cmdRunReport_Click()
On Error GoTo Err_cmdRunReport_Click
Dim MyDB As DAO.Database
Dim qdf As DAO.QueryDef
Dim rcdErrRecSet As DAO.Recordset
Dim rst As DAO.Recordset, rst2 As DAO.Recordset, rstk As DAO.Recordset, rstl As DAO.Recordset, rstm As DAO.Recordset, rstn As DAO.Recordset, _
rstp As DAO.Recordset, rsto As DAO.Recordset
Dim i As Integer, j As Integer, k As Integer, x As Integer, y As Integer, z As Integer, n As Integer, m As Integer
Dim strSQL As String
Dim strFieldList As String, strIN As String
Dim strFieldListk As String, strINk As String, strWhereIN As String, strWhereKIN As String
Dim strINm As String, strINn As String, strIno As String, strinp As String
Dim flgAll As Boolean
Dim strWhere As String
Dim strWherek As String
Set MyDB = CurrentDb()
Dim strOpLinel As String
Dim strOplinek As String
Dim strOpLinem As String
Dim strOplinen As String
Dim strqueryname As String
Dim stroperation2 As String
Dim strSelect As String
Dim fld As DAO.Field
Dim strintotal As String
Dim strInnerjoin As String
Dim strSuggestName As String
Dim intmsgbox As Integer
Dim strOperation As String
Set rst = MyDB.OpenRecordset(&quot;usystablefields&quot;)
Set rstk = MyDB.OpenRecordset(&quot;usystablefieldsk&quot;)
Set rstl = MyDB.OpenRecordset(&quot;usystablefieldsL&quot;)
Set rstm = MyDB.OpenRecordset(&quot;usystablefieldsm&quot;)
Set rstn = MyDB.OpenRecordset(&quot;usystablefieldsn&quot;)
Set rsto = MyDB.OpenRecordset(&quot;usystablefieldso&quot;)
Set rstp = MyDB.OpenRecordset(&quot;usystablefieldsp&quot;)

strSQL = &quot;SELECT &quot;
' j = 0
' k = 0
' l = 0
' m = 0

'SQL STRING FROM TABLE ONE FROM THE FIRST LIST

rst.MoveFirst
'create the IN string by looping thru the listbox
For i = 0 To lstField.ListCount - 1
If lstField.Selected(i) Then
strIN = strIN & &quot;[&quot; & Me!cboTable & &quot;].&quot; & &quot;[&quot; & lstField.Column(0, i) & &quot;] ,&quot;
' rst.Edit
' rst!indexx = k
' rst.Update
rst.MoveNext
' k = k + 1
' Else
' rst.Edit
' rst!indexx = Null
' rst.Update
' rst.MoveNext
End If
' j = j + 1
Next i
'SQL STRING FROM TABLE TWO FROM THE SECOND LIST

If Me!cboTablek = &quot; &quot; Then
Else
rstk.MoveFirst
For x = 0 To lstFieldK.ListCount - 1
If lstFieldK.Selected(x) Then
strINk = strINk & &quot;[&quot; & Me!cboTablek & &quot;].&quot; & &quot;[&quot; & lstFieldK.Column(0, x) & &quot;] ,&quot;
' rstk.Edit
' rstk!indexx = k
' rstk.Update
rstk.MoveNext
' k = k + 1
Else
' rstk.Edit
' rstk!indexx = Null
' rstk.Update
' rstk.MoveNext
End If
' j = j + 1
Next x
' For x = k To lstFieldK.ListCount - 1
' strIN = strIN & &quot;null as Field&quot; & i & &quot;,&quot;
' Next x
' stripoff the last comma of the IN string
'strFieldListk = Left(strINk, Len(strINk) - 1)
End If

' SELECTS FROM TABLE 3 AND ITS FIELDS

If Me!cboTableM = &quot; &quot; Then
Else
rstm.MoveFirst
For y = 0 To lstFieldM.ListCount - 1
If lstFieldM.Selected(y) Then
strINm = strINm & &quot;[&quot; & Me!cboTableM & &quot;].&quot; & &quot;[&quot; & lstFieldM.Column(0, y) & &quot;] ,&quot;
' rst.Edit
' rst!indexx = k
' rst.Update
rstm.MoveNext
' k = k + 1
Else
' rst.Edit
' rst!indexx = Null
' rst.Update
' rst.MoveNext
End If
' j = j + 1
Next y
' For Y = k To lstFieldm.ListCount - 1
' strINm = strINm & &quot;null as Field&quot; & i & &quot;,&quot;
' Next x
' stripoff the last comma of the IN string
'strFieldListm = Left(strINm, Len(strINm) - 1)
End If
'MsgBox (strINm)


If Me!cboTableN = &quot; &quot; Then
Else
rstn.MoveFirst
For z = 0 To lstFieldN.ListCount - 1
If lstFieldN.Selected(z) Then
strINn = strINn & &quot;[&quot; & Me!cboTableN & &quot;].&quot; & &quot;[&quot; & lstFieldN.Column(0, z) & &quot;] ,&quot;
' rst.Edit
' rst!indexx = k
' rst.Update
rstn.MoveNext
' k = k + 1
Else
' rst.Edit
' rst!indexx = Null
' rst.Update
' rst.MoveNext
End If
' j = j + 1
Next z
' For x = k To lstFieldn.ListCount - 1
' strINn = strINn & &quot;null as Field&quot; & i & &quot;,&quot;
' Next x
' stripoff the last comma of the IN string
'strFieldListn = Left(strINn, Len(strINn) - 1)
End If

If Me!cboTableO = &quot; &quot; Then
Else
rsto.MoveFirst
For z = 0 To lstFieldo.ListCount - 1
If lstFieldo.Selected(z) Then
strIno = strIno & &quot;[&quot; & Me!cboTableO & &quot;].&quot; & &quot;[&quot; & lstFieldo.Column(0, z) & &quot;] ,&quot;
' rst.Edit
' rst!indexx = k
' rst.Update
rsto.MoveNext
' k = k + 1
Else
' rst.Edit
' rst!indexx = Null
' rst.Update
' rst.MoveNext
End If
' j = j + 1
Next z
' For x = k To lstFieldo.ListCount - 1
' strINo = strINo & &quot;null as Field&quot; & i & &quot;,&quot;
' Next x
' stripoff the last comma of the IN string
'strFieldListo = Left(strINo, Len(strINno) - 1)
End If

If Me!cboTableP = &quot; &quot; Then
Else
rstp.MoveFirst
For z = 0 To LstFieldP.ListCount - 1
If LstFieldP.Selected(z) Then
strinp = strinp & &quot;[&quot; & Me!cboTableP & &quot;].&quot; & &quot;[&quot; & LstFieldP.Column(0, z) & &quot;] ,&quot;
' rst.Edit
' rst!indexx = k
' rst.Update
rstp.MoveNext
' k = k + 1
Else
' rst.Edit
' rst!indexx = Null
' rst.Update
' rst.MoveNext
End If
' j = j + 1
Next z
' For x = k To lstFieldo.ListCount - 1
' strINp = strINp & &quot;null as Field&quot; & i & &quot;,&quot;
' Next x
' stripoff the last comma of the IN string
'strFieldListp = Left(strINp, Len(strINnp) - 1)
End If


'This will write the SELECT bit for the SQL for the expression

strintotal = strIN & strINk & strINm & strINn & strIno & strinp

'MsgBox strintotal
'Next bif of the Select statements, Sees if you are using the expression builder

If Me!cbotablel = &quot; &quot; Then
strSelect = strIN & strINk & strINm & strINn & strIno & strinp
strintotal = Left(strSelect, Len(strSelect) - 1)
Else
strOpLinel = &quot;[&quot; & Me!cbotablel & &quot;].&quot; & &quot;[&quot; & cboAddFieldL & &quot;]&quot; & Me!cboOperationl & &quot;[&quot; & Me!cbotableq & &quot;].&quot; & &quot;[&quot; & Me!cboAddFieldq & &quot;] As [&quot; & cboAddFieldL & &quot;&quot; & Me!cboOperationl & &quot;&quot; _
& cboAddFieldq & &quot;],&quot;
strOplinek = &quot;[&quot; & Me!cbotablel & &quot;].&quot; & &quot;[&quot; & cboAddFieldL & &quot;]&quot; & Me!cboOperationl & &quot;[&quot; & Me!cbotableq & &quot;].&quot; & &quot;[&quot; & Me!cboAddFieldq & &quot;]&quot; _
& Me!cboOperationk & &quot;[&quot; & Me!cbotabler & &quot;].&quot; & &quot;[&quot; & cboAddFieldr & &quot;] As [&quot; & cboAddFieldL & &quot;&quot; & Me!cboOperationl & &quot;&quot; _
& cboAddFieldq & &quot;&quot; & Me!cboOperationk & &quot;&quot; & cboAddFieldr & &quot;],&quot;

If Me!cboOperationk = &quot; &quot; Then
strOperation = strOperation & strOpLinel
Else
strOperation = strOperation & strOplinek
'MsgBox strOperation
End If
End If

If Me!cbotableS = &quot; &quot; Then
strSelect = strIN & strINk & strINm & strINn & strIno & strinp & strOperation
strintotal = Left(strSelect, Len(strSelect) - 1)
strOperation = &quot;&quot;
Else
strOpLinem = &quot;[&quot; & Me!cbotableS & &quot;].&quot; & &quot;[&quot; & cboAddFieldS & &quot;]&quot; & Me!cbooperations & &quot;[&quot; & Me!cbotableT & &quot;].&quot; & &quot;[&quot; & Me!cboAddFieldT & &quot;] As [&quot; & cboAddFieldS & &quot;&quot; & Me!cbooperations & &quot;&quot; _
& cboAddFieldT & &quot;]&quot;
strOplinen = &quot;[&quot; & Me!cbotableS & &quot;].&quot; & &quot;[&quot; & cboAddFieldS & &quot;]&quot; & Me!cbooperations & &quot;[&quot; & Me!cbotableT & &quot;].&quot; & &quot;[&quot; & Me!cboAddFieldT & &quot;]&quot; _
& Me!cbooperationT & &quot;[&quot; & Me!cbotableU & &quot;].&quot; & &quot;[&quot; & cboAddFieldU & &quot;] As [&quot; & cboAddFieldS & &quot;&quot; & Me!cbooperations & &quot;&quot; _
& cboAddFieldT & &quot;&quot; & Me!cbooperationT & &quot;&quot; & cboAddFieldU & &quot;] &quot;

If Me!cbooperationT = &quot; &quot; Then
stroperation2 = stroperation2 & strOpLinem
Else
stroperation2 = stroperation2 & strOplinen
'MsgBox stroperation2
End If
End If
'Inner Join operation selects depending of how many tables are being used

If Me!cboTablek = &quot; &quot; Then
strInnerjoin = &quot;[&quot; & Me!cboTable & &quot;]&quot;
ElseIf Me!cboTableM = &quot; &quot; Then
strInnerjoin = &quot;[&quot; & Me!cboTable & &quot;] INNER JOIN &quot; & &quot;[&quot; & Me!cboTablek & &quot;] on &quot; & &quot;[&quot; & Me!cboTable & &quot;].ID&quot; & &quot; = &quot; & &quot;[&quot; & Me!cboTablek & &quot;].ID&quot;
ElseIf Me!cboTableN = &quot; &quot; Then
strInnerjoin = &quot;([&quot; & Me!cboTable & &quot;] INNER JOIN &quot; & &quot;[&quot; & Me!cboTablek & &quot;] on &quot; & &quot;[&quot; & Me!cboTable & &quot;].ID&quot; & &quot; = &quot; & &quot;[&quot; & Me!cboTablek & &quot;].ID)&quot; _
& &quot; INNER JOIN &quot; & &quot;[&quot; & Me!cboTableM & &quot;] on &quot; & &quot;[&quot; & Me!cboTable & &quot;].ID&quot; & &quot; = &quot; & &quot;[&quot; & Me!cboTableM & &quot;].ID&quot;
ElseIf Me!cboTableO = &quot; &quot; Then
strInnerjoin = &quot;(([&quot; & Me!cboTable & &quot;] INNER JOIN &quot; & &quot;[&quot; & Me!cboTablek & &quot;] on &quot; & &quot;[&quot; & Me!cboTable & &quot;].ID&quot; & &quot; = &quot; & &quot;[&quot; & Me!cboTablek & &quot;].ID)&quot; _
& &quot; INNER JOIN &quot; & &quot;[&quot; & Me!cboTableM & &quot;] on &quot; & &quot;[&quot; & Me!cboTable & &quot;].ID&quot; & &quot; = &quot; & &quot;[&quot; & Me!cboTableM & &quot;].ID)&quot; _
& &quot; INNER JOIN &quot; & &quot;[&quot; & Me!cboTableN & &quot;] on &quot; & &quot;[&quot; & Me!cboTable & &quot;].ID&quot; & &quot; = &quot; & &quot;[&quot; & Me!cboTableN & &quot;].ID&quot;
ElseIf Me!cboTableP = &quot; &quot; Then
strInnerjoin = &quot;((([&quot; & Me!cboTable & &quot;] INNER JOIN &quot; & &quot;[&quot; & Me!cboTablek & &quot;] on &quot; & &quot;[&quot; & Me!cboTable & &quot;].ID&quot; & &quot; = &quot; & &quot;[&quot; & Me!cboTablek & &quot;].ID)&quot; _
& &quot; INNER JOIN &quot; & &quot;[&quot; & Me!cboTableM & &quot;] on &quot; & &quot;[&quot; & Me!cboTable & &quot;].ID&quot; & &quot; = &quot; & &quot;[&quot; & Me!cboTableM & &quot;].ID)&quot; _
& &quot; INNER JOIN &quot; & &quot;[&quot; & Me!cboTableN & &quot;] on &quot; & &quot;[&quot; & Me!cboTable & &quot;].ID&quot; & &quot; = &quot; & &quot;[&quot; & Me!cboTableN & &quot;].ID)&quot; _
& &quot; INNER JOIN &quot; & &quot;[&quot; & Me!cboTable0 & &quot;] on &quot; & &quot;[&quot; & Me!cboTable & &quot;].ID&quot; & &quot; = &quot; & &quot;[&quot; & Me!cboTable0 & &quot;].ID&quot;
Else
strInnerjoin = &quot;(((([&quot; & Me!cboTable & &quot;] INNER JOIN &quot; & &quot;[&quot; & Me!cboTablek & &quot;] on &quot; & &quot;[&quot; & Me!cboTable & &quot;].ID&quot; & &quot; = &quot; & &quot;[&quot; & Me!cboTablek & &quot;].ID)&quot; _
& &quot; INNER JOIN &quot; & &quot;[&quot; & Me!cboTableM & &quot;] on &quot; & &quot;[&quot; & Me!cboTable & &quot;].ID&quot; & &quot; = &quot; & &quot;[&quot; & Me!cboTableM & &quot;].ID)&quot; _
& &quot; INNER JOIN &quot; & &quot;[&quot; & Me!cboTableN & &quot;] on &quot; & &quot;[&quot; & Me!cboTable & &quot;].ID&quot; & &quot; = &quot; & &quot;[&quot; & Me!cboTableN & &quot;].ID)&quot; _
& &quot; INNER JOIN &quot; & &quot;[&quot; & Me!cboTableO & &quot;] on &quot; & &quot;[&quot; & Me!cboTable & &quot;].ID&quot; & &quot; = &quot; & &quot;[&quot; & Me!cboTableO & &quot;].ID)&quot; _
& &quot; INNER JOIN &quot; & &quot;[&quot; & Me!cboTableP & &quot;] on &quot; & &quot;[&quot; & Me!cboTable & &quot;].ID&quot; & &quot; = &quot; & &quot;[&quot; & Me!cboTableP & &quot;].ID&quot;
End If

'MsgBox strInnerjoin
strSQL = strSQL & strintotal & strOperation & stroperation2 & &quot;FROM &quot; & strInnerjoin
' MsgBox strSQL



'create the WhereIN string by looping thru the listbox

If Me!cboFieldName = &quot; &quot; Then
strSQL = strSQL
Else
For i = 0 To lstCriteria.ListCount - 1
If lstCriteria.Selected(i) Then
If lstCriteria.Column(0, i) = &quot;All&quot; Then
flgAll = True
End If

' Check data type of field for delimiting
If cboFieldName.Column(1) >= 1 And cboFieldName.Column(1) <= 7 Then
' If the field holds numeric data
strWhereIN = strWhereIN & &quot; &quot; & lstCriteria.Column(0, i) & &quot;,&quot;
ElseIf cboFieldName.Column(1) = 8 Then
'field is date
strWhereIN = strWhereIN & &quot;#&quot; & lstCriteria.Column(0, i) & &quot;#,&quot;
ElseIf cboFieldName.Column(1) = 10 Then
'field is text
strWhereIN = strWhereIN & &quot;'&quot; & lstCriteria.Column(0, i) & &quot;',&quot;
End If
End If
Next i
'create the WHERE string, stripping off the last comma of the IN string
strWhere = &quot; WHERE [&quot; & Me!cboTable & &quot;].[&quot; & Me!cboFieldName & &quot;] in (&quot; & Left(strWhereIN, Len(strWhereIN) - 1) & &quot;)&quot;
' MsgBox strWhere
'if &quot;All&quot; was selected, don't add the WHERE condition
If Not flgAll Then
strSQL = strSQL & strWhere
End If
End If

If Me!cboFieldName2 = &quot; &quot; Then
Else
For i = 0 To kstCriteria.ListCount - 1
If kstCriteria.Selected(i) Then
If kstCriteria.Column(0, i) = &quot;All&quot; Then
flgAll = True
End If

' Check data type of field for delimiting
If cboFieldName2.Column(1) >= 1 And cboFieldName2.Column(1) <= 7 Then
' If the field holds numeric data
strWhereKIN = strWhereKIN & &quot; &quot; & kstCriteria.Column(0, i) & &quot;,&quot;
ElseIf cboFieldName2.Column(1) = 8 Then
'field is date
strWhereKIN = strWhereKIN & &quot;#&quot; & kstCriteria.Column(0, i) & &quot;#,&quot;
ElseIf cboFieldName2.Column(1) = 10 Then
'field is text
strWhereKIN = strWhereKIN & &quot;'&quot; & kstCriteria.Column(0, i) & &quot;',&quot;
End If
End If
Next i
'create the WHERE string, stripping off the last comma of the IN string
strWherek = &quot; AND [&quot; & Me!cboTable & &quot;].[&quot; & Me!cboFieldName2 & &quot;] in (&quot; & Left(strWhereKIN, Len(strWhereKIN) - 1) & &quot;)&quot;
'MsgBox strWhereK
'if &quot;All&quot; was selected, don't add the WHERE condition
If Not flgAll Then
strSQL = strSQL & strWherek
End If
End If

On Error Resume Next
strqueryname = [textval]
Select Case Err
Case 0
On Error GoTo 0 'No error
Case 94
On Error GoTo 0 'No error a name was typed in
If Me!cboTablek = &quot; &quot; Then
strSuggestName = &quot;qry Search &quot; & Me!cboTable
[textval] = strSuggestName
ElseIf Me!cboTableM = &quot; &quot; Then
strSuggestName = &quot;qry Search &quot; & Me!cboTable & &quot; &quot; & Me!cboTablek & &quot;&quot;
[textval] = strSuggestName
MsgBox &quot;You have not entered a name to save file. A default name (&quot; & strSuggestName & &quot;) has been entered for you&quot;
ElseIf Me!cboTableN = &quot; &quot; Then
strSuggestName = &quot;qry Search &quot; & Me!cboTable & &quot; to &quot; & Me!cboTableM & &quot;&quot;
[textval] = strSuggestName
MsgBox &quot;You have not entered a name to save file. A default name (&quot; & strSuggestName & &quot;) has been entered for you&quot;
ElseIf Me!cboTableO = &quot; &quot; Then
strSuggestName = &quot;qry Search &quot; & Me!cboTable & &quot; to &quot; & Me!cboTableN & &quot;&quot;
[textval] = strSuggestName
MsgBox &quot;You have not entered a name to save file. A default name (&quot; & strSuggestName & &quot;) has been entered for you&quot;
Else
strSuggestName = &quot;qry Search &quot; & Me!cboTable & &quot; to &quot; & Me!cboTableP & &quot;&quot;
[textval] = strSuggestName
MsgBox &quot;You have not entered a name to save file. A default name(&quot; & strSuggestName & &quot;) has been entered for you&quot;
End If


End Select

If [textval] = &quot;&quot; Then
If Me!cboTablek = &quot; &quot; Then
strSuggestName = &quot;qry Search &quot; & Me!cboTable
[textval] = strSuggestName
ElseIf Me!cboTableM = &quot; &quot; Then
strSuggestName = &quot;qry Search &quot; & Me!cboTable & &quot; &quot; & Me!cboTablek & &quot;&quot;
[textval] = strSuggestName
MsgBox &quot;You have not entered a name to save file. A default name (&quot; & strSuggestName & &quot;) has been entered for you&quot;
ElseIf Me!cboTableN = &quot; &quot; Then
strSuggestName = &quot;qry Search &quot; & Me!cboTable & &quot; to &quot; & Me!cboTableM & &quot;&quot;
[textval] = strSuggestName
MsgBox &quot;You have not entered a name to save file. A default name (&quot; & strSuggestName & &quot;) has been entered for you&quot;
ElseIf Me!cboTableO = &quot; &quot; Then
strSuggestName = &quot;qry Search &quot; & Me!cboTable & &quot; to &quot; & Me!cboTableN & &quot;&quot;
[textval] = strSuggestName
MsgBox &quot;You have not entered a name to save file. A default name (&quot; & strSuggestName & &quot;) has been entered for you&quot;
Else
strSuggestName = &quot;qry Search &quot; & Me!cboTable & &quot; to &quot; & Me!cboTableP & &quot;&quot;
[textval] = strSuggestName
MsgBox &quot;You have not entered a name to save file. A default name(&quot; & strSuggestName & &quot;) has been entered for you&quot;
End If
End If


strqueryname = [textval]
DoCmd.Close acQuery, strqueryname
On Error Resume Next
Set rcdErrRecSet = MyDB.OpenRecordset(strqueryname)
Select Case Err
Case 0
On Error GoTo 0 'No error Table--table must exist
On Error GoTo Err_cmdRunReport_Click
intmsgbox = MsgBox(&quot;The &quot; & strqueryname & &quot; already exists. Press 'YES' to OVERWRITE the query or 'NO' to save file as a different name?&quot;, 52)
If intmsgbox = 6 Then
MyDB.QueryDefs.Delete (strqueryname)
Set qdf = MyDB.CreateQueryDef(strqueryname, strSQL)
DoCmd.OpenQuery (strqueryname)
Else
rcdErrRecSet.Close
MsgBox &quot;Please Enter A New Name&quot;
[textval].SetFocus
End If

Case 3011, 3078
On Error GoTo 0 'Table does not exists so make one.
On Error GoTo Err_cmdRunReport_Click
Set qdf = MyDB.CreateQueryDef(strqueryname, strSQL)
DoCmd.OpenQuery (strqueryname)

Case 3062
On Error GoTo 0
On Error GoTo Err_cmdRunReport_Click
MsgBox &quot;You have entered the same expression (in the both expression builders). This creates a duplicate field names. Please change one of expressions. If this is not the case please find the query manually and delete it.&quot;
GoTo Exit_cmdRunReport_Click


Case 3061
On Error GoTo 0 'No error Table--table must exist
On Error GoTo Err_cmdRunReport_Click
intmsgbox = MsgBox(&quot;The &quot; & strqueryname & &quot; already exists. Press 'YES' to OVERWRITE the query or 'NO' to save file as a different name?&quot;, 52)
If intmsgbox = 6 Then
MyDB.QueryDefs.Delete (strqueryname)
Set qdf = MyDB.CreateQueryDef(strqueryname, strSQL)
DoCmd.OpenQuery (strqueryname)
Else
MsgBox &quot;Please Enter A New Name&quot;
[textval].SetFocus
End If
End Select


Exit_cmdRunReport_Click:
Exit Sub



Err_cmdRunReport_Click:
If Err.Number = 3265 Then '*** if the error is the query is missing
Resume Next '*** then skip the delete line and resume on the next line
ElseIf Err.Number = 5 Then
MsgBox &quot;You must make a selection! You have selected a table or field and not filled in the criteria. Please go back and check, alternatively press the RESET button to restart your search.&quot;, , &quot;Missing Criteria Error&quot;
Resume Exit_cmdRunReport_Click
ElseIf Err.Number = 3135 Then
MsgBox &quot;Unable to complete process. The probable cause of the error is that you have selected to tables that are the same. Please check that all tables chosen are different. If this is not the problem the tables probably do not have an ID field which is the primary key please set this to use this form. For further information about this please see help file provided with the Financials Data help file&quot;, , &quot; SQL Error in the Join Operation&quot;
Resume Exit_cmdRunReport_Click
ElseIf Err.Number = 3296 Then
MsgBox &quot;Unable to complete process. The probable cause of the error is that you have selected to tables that are the same. Please check that all tables chosen are different. If this is not the problem the tables probably do not have an ID field which is the primary key please set this to use this form. For further information about this please see help file provided with the Financials Data help file&quot;, , &quot; SQL Error in the Join Operation&quot;
Resume Exit_cmdRunReport_Click
ElseIf Err.Number = 3126 Then
MsgBox &quot;You have selected but not filled in one of fields in one of the query expressions. Please redo the query or fill it in with a valid field.&quot;
Resume Exit_cmdRunReport_Click
ElseIf Err.Number = 3125 Then
MsgBox &quot;Sorry the suggested name is too long or contains invalid characters, you will have to type in the name manually.&quot;, , &quot;Sorry Invalid Save Name File&quot;
[textval].SetFocus
Resume Exit_cmdRunReport_Click
Else
MsgBox Err.Description '*** write out the error and exit the sub
Resume Exit_cmdRunReport_Click
End If

End Sub
 
RamziSaab,
I went to your site and was looking for a database called &quot;search.mdb&quot; to download and couldn't find it. I think you emailed me a copy of this awhile ago. If you have this database, could you please email it too me again, or tell me where I can get it?

My email address is: jbento1966@comcast.net.

Thanks for any help,

Jerome Benton
JERPAT Web Designs
GOD Is Good All The Time!!!
 
RamziSaab,
Forget my request, I found the database, but thanks anyway, and HAVE A GREAT WEEKEND!!!!

Jerome Benton
JERPAT Web Designs
GOD Is Good All The Time!!!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top