Easy Thing just stumping me (1 Viewer)

Cliff67

Registered User.
Local time
Today, 07:41
Joined
Oct 16, 2018
Messages
175
Hi Everyone
I've got a module that populates several date boxes on a form based on the history table. Not difficult I hear you say...However I just can't see what I'm doing wrong I keep getting an error saying Too Few parameters

Here the code I'm using to find the dates

Set rs = db.OpenRecordset("Select * from Tbl_Tickets_History where TSNo = " & Me.Ticket_Number & " AND Status = " & "'First Contact'")

So I'm opening a recordset based on the TSno on the form and looking for all "First Contact"s within the status.

I just can't see what I'm doing wrong :banghead:
Any help would be much appreciated

Cliff
 

Minty

AWF VIP
Local time
Today, 14:41
Joined
Jul 26, 2013
Messages
10,354
Assuming that the TSNo is a string and not a number you need

Code:
Set rs = db.OpenRecordset("Select * from Tbl_Tickets_History where TSNo = '" & Me.Ticket_Number & "' AND [Status] = 'First Contact'")

The second part of your concatenation isn't needed, so I have simplified that, and Status for some reason I think is a reserved word so square brackets just to be safe.
 

Cliff67

Registered User.
Local time
Today, 07:41
Joined
Oct 16, 2018
Messages
175
Thanks Minty
 

Mark_

Longboard on the internet
Local time
Today, 07:41
Joined
Sep 12, 2017
Messages
2,111
I normally suggest declaring a string variable to hold your SQL, fill in the string variable, then use it in your OpenRecordSet. This makes some of this much easier to debug when you can show exactly what is being passed prior to passing it.
 

Cliff67

Registered User.
Local time
Today, 07:41
Joined
Oct 16, 2018
Messages
175
Thanks guys
Got it working then had to deal with no records so added a little bit to check for 0 records and it all works well. I basically wanted to display the last date in a series, this was just the first contact but the others were reply, interaction and Closed so all good
 

Users who are viewing this thread

Top Bottom