PDA

View Full Version : Search box prompt only returns back dates rather than other searches on the criteria



wedd
09-21-2011, 05:03 AM
Hi All,

I'm trying to run a search through records where the user enters the year they want to make the booking; of the venue and a messagebox that pops up to display whether the venue, time, date is available or not available based on a search through the records...it's important that the times are not double booked unless cancelled. I've entered the following code but it only allows the user to enter a date; and returns back a message that the date is unavailable, but I would like to add the other criterias in the search. The code is below:

Is there a solution to do this procedure? If so, how can this be done?

Private Sub Command9_Click()
Dim SearchAndDisplayABooking
SearchAndDisplayABooking = InputBox("Enter the date to check if it's available")
MsgBox "This booking is available on " & DateDiff("yyyy", SearchAndDisplayABooking, _
Date) & "date."



Thanks for your contributions:friends:




End Sub

hansup
09-21-2011, 09:50 AM
Create a SELECT query which expresses the search you want to perform. Maybe it would look something like this:

SELECT *
FROM YourTable
WHERE
[booking_datetime_field] = #your search date here#
AND [venue_field] = 'the venue field value you want to find';
If you can do that, use the WHERE clause, without the word "WHERE", as the Criteria argument to the DCount() function.

If DCount("*", "YourTable", "your criteria here") > 0 Then
MsgBox "Previous booking found."
Else
MsgBox "No booking found."
End If