C
Charles D Clayton Jr
I have a database of drawing names. Contained within the drawing name
are 'location,' 'size,' 'service,' 'spec' and 'line number.' An
Example would be BPD-10-PF-A-9081-1. Everything is separated by "-"
(Dashes) but not everything is a consistent number of characters.
However, I can generate the queries to extract the information from
the drawing number using "left", "Mid", "Right" & "InStr" functions
without any problems at all. But in trying to develop a search form
for other people I am encountering problems. I keep getting the error
#13 "Type mismatch". Here is some of the code:
Private Sub FindRecords_Click()
On Err GoTo Err_FindRecords_Click
Dim db As Database
Dim q As QueryDef
Dim strSQL As String
Dim line As String
' Create the query based on the information on the form
strSQL = "SELECT isos.* FROM Isos WHERE "
' Extract Size information from Iso
strSQL = strSQL & "(left([iso],3)) Like """ & Me![cLocation] & """"
strSQL = strSQL & " AND "
'strSQL = strSQL & "(Mid([iso],5,2)) Like """ & Me![cSize] & """"
(Test-Passed)
strSQL = strSQL & "AND "
'strSQL = strSQL & "(Mid([iso],((InStr([iso]," -
"))+1),((InStr(InStr([iso]," - ")+1,[iso]," - "))-(InStr([Iso]," -
"))-1))) Like """ & Me![cSize] & """"
strSQL = strSQL & "(Mid([Iso],(InStr(InStr(InStr([Iso]," -
")+1,[Iso]," - ")+1,[iso]," - ")+1),1)) Like """ & Me![cSpec] & """"
' Delete the previous query
db.QueryDefs.Delete "qFindRecordsTest"
Set q = db.CreateQueryDef("qFindRecordsTest", strSQL)
' Open the query
DoCmd.OpenQuery "qFindRecordsTest", acViewNormal, acEdit
Exit_FindRecords_Click:
Exit Sub
I found the location first using "left" and it worked find. I then
added size and that is when I started getting errors. I considered
that there was somthing about using "Mid" so I put a real simple
construction and it worked fine. Does anybody have any suggestions?
Thanks,
Charles D Clayton Jr
are 'location,' 'size,' 'service,' 'spec' and 'line number.' An
Example would be BPD-10-PF-A-9081-1. Everything is separated by "-"
(Dashes) but not everything is a consistent number of characters.
However, I can generate the queries to extract the information from
the drawing number using "left", "Mid", "Right" & "InStr" functions
without any problems at all. But in trying to develop a search form
for other people I am encountering problems. I keep getting the error
#13 "Type mismatch". Here is some of the code:
Private Sub FindRecords_Click()
On Err GoTo Err_FindRecords_Click
Dim db As Database
Dim q As QueryDef
Dim strSQL As String
Dim line As String
' Create the query based on the information on the form
strSQL = "SELECT isos.* FROM Isos WHERE "
' Extract Size information from Iso
strSQL = strSQL & "(left([iso],3)) Like """ & Me![cLocation] & """"
strSQL = strSQL & " AND "
'strSQL = strSQL & "(Mid([iso],5,2)) Like """ & Me![cSize] & """"
(Test-Passed)
strSQL = strSQL & "AND "
'strSQL = strSQL & "(Mid([iso],((InStr([iso]," -
"))+1),((InStr(InStr([iso]," - ")+1,[iso]," - "))-(InStr([Iso]," -
"))-1))) Like """ & Me![cSize] & """"
strSQL = strSQL & "(Mid([Iso],(InStr(InStr(InStr([Iso]," -
")+1,[Iso]," - ")+1,[iso]," - ")+1),1)) Like """ & Me![cSpec] & """"
' Delete the previous query
db.QueryDefs.Delete "qFindRecordsTest"
Set q = db.CreateQueryDef("qFindRecordsTest", strSQL)
' Open the query
DoCmd.OpenQuery "qFindRecordsTest", acViewNormal, acEdit
Exit_FindRecords_Click:
Exit Sub
I found the location first using "left" and it worked find. I then
added size and that is when I started getting errors. I considered
that there was somthing about using "Mid" so I put a real simple
construction and it worked fine. Does anybody have any suggestions?
Thanks,
Charles D Clayton Jr