"Douglas J. Steele" wrote in message
You'll have to show us the rest of your code. Assigning a SQL statement to
a string, by itself, cannot possibly generate an 424 error.
Okey dokey; here are the two procedures, three ways. First, these are the
procedures that worked fine:
Sub ImageFile(ctlImagePath As Control, ctlSubfolder As Control,
ctlImagePrefix As Control, _
iSpace As Integer, iDigits As Integer, ctlSequence As Control,
ctlFileExt As Control, _
strWholeName As String, strImageFile As String)
Dim strDigits As String
strWholeName = ctlImagePath
strWholeName = strWholeName & ctlImagePrefix
If iSpace = 1 Then
strWholeName = strWholeName & " "
strImageFile = ctlImagePrefix & " "
Else
strImageFile = ctlImagePrefix
End If
ctlSequence.SetFocus
Select Case iDigits - Len(ctlSequence.Text)
Case 0
strDigits = ctlSequence.Text
Case 1
strDigits = "0" & ctlSequence.Text
Case 2
strDigits = "00" & ctlSequence.Text
Case 3
strDigits = "000" & ctlSequence.Text
Case 4
strDigits = "0000" & ctlSequence.Text
End Select
strWholeName = strWholeName & strDigits & ctlFileExt
strImageFile = strImageFile & strDigits & ctlFileExt
End Sub
Private Sub cmdTest_Click()
Dim strFileName As String, strImageFile As String
Call ImageFile(Me!txtImagePath, Me!txtSubfolder, Me!txtImagePrefix, _
Me!txtSpace, Me!txtDigits, Me!txtSequence, Me!txtFileExt, strFileName,
strImageFile)
Me!txtFullPath = strFileName
Me!ImgFrame1.Picture = strFileName
Me!txtImageFile = strImageFile
Me!txtCaption.SetFocus
End Sub
Then I tried to add a recordset operation thusly. This gave me the 424
error:
Sub ImageFile(ctlImagePath As Control, ctlSubfolder As Control,
ctlImagePrefix As Control, _
iSpace As Integer, iDigits As Integer, ctlSequence As Control,
ctlFileExt As Control, _
strWholeName As String, strImageFile As String)
Dim strDigits As String
strWholeName = ctlImagePath
strWholeName = strWholeName & ctlImagePrefix
If iSpace = 1 Then
strWholeName = strWholeName & " "
strImageFile = ctlImagePrefix & " "
Else
strImageFile = ctlImagePrefix
End If
ctlSequence.SetFocus
Select Case iDigits - Len(ctlSequence.Text)
Case 0
strDigits = ctlSequence.Text
Case 1
strDigits = "0" & ctlSequence.Text
Case 2
strDigits = "00" & ctlSequence.Text
Case 3
strDigits = "000" & ctlSequence.Text
Case 4
strDigits = "0000" & ctlSequence.Text
End Select
strWholeName = strWholeName & strDigits & ctlFileExt
strImageFile = strImageFile & strDigits & ctlFileExt
Dim rstCaption As DAO.Recordset, dbs As DAO.Database
Dim strSelect As String
strSelect = "SELECT * FROM Images WHERE ProjectNo = '" & ctlProjectNo.Text &
"' AND ImagePrefix = '" & ctlImagePrefix.Text _
& "' AND Subfolder = '" & ctlSubfolder.Text & "' AND Sequence = " &
ctlSequence.Text & "' AND FileExt = '" _
& ctlFileExt & "'"
Set dbs = CurrentDb
Set rstCaption = dbs.OpenRecordset(strCaption)
End Sub
Private Sub cmdTest_Click()
Dim strFileName As String, strImageFile As String
Call ImageFile(Me!txtImagePath, Me!txtSubfolder, Me!txtImagePrefix, _
Me!txtSpace, Me!txtDigits, Me!txtSequence, Me!txtFileExt, strFileName,
strImageFile)
Me!txtFullPath = strFileName
Me!ImgFrame1.Picture = strFileName
Me!txtImageFile = strImageFile
Me!txtCaption.SetFocus
End Sub
Then I tried adding the Table as a variable. This gave me the ByRef error:
Sub ImageFile(ctlImagePath As Control, ctlSubfolder As Control,
ctlImagePrefix As Control, _
iSpace As Integer, iDigits As Integer, ctlSequence As Control,
ctlFileExt As Control, _
strWholeName As String, strImageFile As String, objTable as Object)
Dim strDigits As String
strWholeName = ctlImagePath
strWholeName = strWholeName & ctlImagePrefix
If iSpace = 1 Then
strWholeName = strWholeName & " "
strImageFile = ctlImagePrefix & " "
Else
strImageFile = ctlImagePrefix
End If
ctlSequence.SetFocus
Select Case iDigits - Len(ctlSequence.Text)
Case 0
strDigits = ctlSequence.Text
Case 1
strDigits = "0" & ctlSequence.Text
Case 2
strDigits = "00" & ctlSequence.Text
Case 3
strDigits = "000" & ctlSequence.Text
Case 4
strDigits = "0000" & ctlSequence.Text
End Select
strWholeName = strWholeName & strDigits & ctlFileExt
strImageFile = strImageFile & strDigits & ctlFileExt
Dim rstCaption As DAO.Recordset, dbs As DAO.Database
Dim strSelect As String
strSelect = "SELECT * FROM " & objTable & " WHERE ProjectNo = '" &
ctlProjectNo.Text & "' AND ImagePrefix = '" & ctlImagePrefix.Text _
& "' AND Subfolder = '" & ctlSubfolder.Text & "' AND Sequence = " &
ctlSequence.Text & "' AND FileExt = '" _
& ctlFileExt & "'"
Set dbs = CurrentDb
Set rstCaption = dbs.OpenRecordset(strCaption)
End Sub
Private Sub cmdTest_Click()
Dim strFileName As String, strImageFile As String
Call ImageFile(Me!txtImagePath, Me!txtSubfolder, Me!txtImagePrefix, _
Me!txtSpace, Me!txtDigits, Me!txtSequence, Me!txtFileExt, strFileName,
strImageFile, Images)
Me!txtFullPath = strFileName
Me!ImgFrame1.Picture = strFileName
Me!txtImageFile = strImageFile
Me!txtCaption.SetFocus
End Sub
Thanks for looking at this.
Joe