Originally Posted by
Gicu
I agree that your table is probably not normalized if you have Item1,Item2,....Item15. Those should be individual records in a separate table which stores the PK of the original table as a FK and One field for Item. What would happen when you get the 16th item and don't have a place to store it in?
For the question at hand I think the easiest way is to concatenate the 15 fields in the form's recordsource (ITEMS:"|" & [Item1] & "|" & [Item2] & "|" & ....& [Item15] & "|") then in the filter button code get the records that match using Instr("ITEMS","|" & Me.txtUnboundItemSearch) & "|")>0.
Cheers,
Hi @Gicu. Yeah it is a bit repetitive to make 15 fields for one record but the thing is we send out one request per day for 15 items and we just want that to be recorded as one record. When we get to developing the query section I would like to just search for items with one unbound text box in a split form just to see how many times we requested for that item. We never ask for 16 items as 15 is the max. If anything, some days may be less than 15 but we always try to max it out to make the request as worth while as possible.
Right now I am having issues with this line for creating a PDF out of this form with the 15 fields and I think it's because of the date because if I remove the Me.DateSent part it will work. I think it can't figure out what to do with the format of the date because the date sent field has slashes (02/09/2023) and file names cannot contain slashes. Can you help with this? I would like the PDF to save in this format:
Example 2-9-23_Ref#.pdf
Here is the code:
Code:
Private Sub cmdExportToPDF_Click()Dim FileName As String
Dim FilePath As String
If Me.NewRecord And Me.Dirty Then
MsgBox "Please Save Record Before Exporting.", vbInformation, "Requirement"
Me.txtLP1.SetFocus
Exit Sub
End If
If Me.NewRecord And Me.Dirty = False Then
MsgBox "Please Create And Save Record Before Exporting.", vbInformation, "Requirement"
Me.txtLP1.SetFocus
Exit Sub
End If
If MsgBox("Export Record To PDF?", vbYesNo, "Export") = vbYes Then
FileName = "Example " & Me.DateSent & "_"& Me.txtRefNum
FilePath = "D:\TEST FOLDER\Ready\" & FileName & ".pdf"
'FilePath = CreateObject("WScript.Shell").SpecialFolders("Desktop") & "\" & FileName & ".pdf"
DoCmd.OutputTo acOutputForm, "Request Form", acFormatPDF, FilePath
MsgBox "PDF File Was Exported As (Example Date_Ref#.pdf) To Network Folder.", _
vbInformation, "Notification"
Me.txtRefNum.SetFocus
Else
Me.txtRefNum.SetFocus
End If
End Sub
Also should mention that when I got it to work without the date sent, it exported the whole recordset. Not just the record I was looking at. Do you know how to fix that?
Thank you for your help in advance.