Modules & VBA :: Search Form / Searching By Date

Jun 3, 2014

The database is a patient database used for tracking Inpatient data and Handover (or Handoffs for those in the US). It has been merrily ticking over since December and has accrued several thousand records. To get access to this data in new and interesting ways Im trying evolve my rudimentary search function which currently only works for diagnosis, name and consultant (in otherword text fields).

Thus I have an unbound form that has various input boxes on it. I have borrowed some code to power the form and have replaced with own fields:

Code:

Dim criteria As String

Looks for input text and adds it to the final criteria to power the search list at the end based on field in this case txtDiagnosis

If Not IsNull(Me.txtDiagnosis) Then

If criteria <> "" Then criteria criteria & " and "
criteria = criteria & "txtDiagnosis like " & Chr(34) & "*" & Me.txtDiagnosis & "*" & Chr(34)
End If

[code]...

ISSUE 1:
I am struggling with the date search function. It doesn't work. Whether it is prudent to search for either a admitted date or a discharged date?

ISSUE 2:
I have a check box for "complications" that I'd like to be included on in the search.

View Replies


ADVERTISEMENT

Searching For Value Range On A Custom Search Form

Jun 9, 2014

I built a custom search form that uses unbound text boxes to set the criteria for a query. For example, I have an unbound text box, LastName on my search form. Then in the query, I set the criteria to Like "*"&[Forms]![SearchForm]![LastName]&"*". This returns all records if the text box is left blank or returns those records that match the text box if it isn't.

I would like to do the same thing but instead of searching a text field, I want to search a number field. And I want to search for a range of values aka >10 instead of just a single value. I still need the query to return all records if the text box is left blank.

View 8 Replies View Related

Modules & VBA :: Searching For A Variable With Date Criteria In Table

Jun 14, 2013

I'm trying to search for a variable (varCod) in a table(SerialNumberCustomer) but I want to only store the returned variable in an array if its shipDate is between 9/30/2001 and 10/1/2012

this is what my code looks like so far:

Set rst = CurrentDb.OpenRecordset( _
"Select * from SerialNumberCustomer WHERE SerialCardId = " & varCod & " AND (ShipDate BETWEEN #09/30/2001# AND #10/01/2012#) ")

The line of code works and it returns all of the values in SerialCardId where it's = to varCode but it doesn't go through with the shipDate requirement. It's instead returning all of the dates with the found value.

View 13 Replies View Related

Modules & VBA :: Searching Form Along With Other Forms In One Navigation Form

Jun 11, 2013

I have used one of the members' code which was posted in a tread before to create a search box in a form. This code works perfectly when the form itself is open. Otherwise, when I put this searching form along with other forms in one navigation form, I get the following error: "Enter Parameter Value: Forms!FRM_SearchMulti!SrchText"...The code that was used for the Search box is as following:

Private Sub SearchFor_Change()
'Create a string (text) variable
Dim vSearchString As String
'Populate the string variable with the text entered in the Text Box SearchFor
vSearchString = SearchFor.Text

[code]....

View 7 Replies View Related

Question About Searching For One Date Accross Multiple Date Fields. Thanks!

Jan 12, 2007

I am currently building a booking and invoicing database for the small business where I work. One aspect of this database allows you to enter an employee name and schedule days off via a form I have already built. To access this information I would like a parameter query where you can enter a date once and then have this date looked up across a number of date fields. Here are my table column headings:

ID
Employee Name
Date 1
Date 2
Date 3
Date 4
Date 5
Date 6
Date 7
....etc

So, basically, the parameter query would ask "What date?" which the person would enter, and then search all 12 date fields to see if the date was contained in any one of them. Then it would pull any records which did have the date in one of the fields.

It seems really simple but I have searched and searched and can't seem to find the answer. Tried a multivalue field but does not seem to work.

Thanks very much, any help appreciated! Elspeth :confused:

View 14 Replies View Related

Date Searching

Nov 12, 2005

I have a date base where i am looking for all records which are not scanned every time an order is entered a date is generated. I then want to find all the ones which have not scanned for today. (i know i can do this by a query i.e [Date] =date() .)

Now the problem is that if nothing is entered in today for example i then want to find the next day something was entered.

I am a novice with access and i think there must be some coding which i need to create in a module prehaps but i am unsure. Could any one assist??

View 6 Replies View Related

Searching By Date Reference...

Nov 26, 2007

Hi,

i have a START date "DD/MM/YYYY" <-- with 3 combo boxes "cboStartDD", "cboStartMM", "cboStartYYYY".

i have a END date "DD/MM/YYYY" <-- with 3 combo boxes "cboEndDD", "cboEndMM", "cboEndYYYY".

i have a Search command buttom.

upon a "search" button is click,

how can i search the dates in the table with "tblDate" (column) that matches the date ranges from the START date to the END date?

by using sql statement...

thank you.

View 5 Replies View Related

Searching For Records Between A Certain Date

Dec 2, 2007

Lets say i have records that contain the following dates

09/06/07

14/06/07

20/06/07

31/06/07

14/07/07

And i wanted to know what records contain anything between 09/06/07 and 31/06/07 so it would show the records that have this in the date field

09/06/07

14/06/07

20/06/07

31/06/07

What would be the best way to do this

Thanks in advance

View 10 Replies View Related

Make A Form Which Search Between Beginning And End Date Range

Jul 11, 2015

I have created a database based off of 1 table that holds all of my data. I need to create a form that queries off of the following columns from my table.

Acceptance Date

Sales Rep Name
Sales Region

I want to make a form which searches between a beginning and end date range, Sales Rep Name & Sales Region that can be pulled from these 3 queried selections all from the same form.

View 2 Replies View Related

Search Date Range By Month In Combo Box Within A Form?

May 25, 2012

I'm trying to create a combo list box in a form that has all 12 months (January, February......etc,) listed in rows, and depending on the selection will bring up only that particular month within a range of dates from a table. I don't want it to look at the day or the year, but only the month.

Example: I select January from the drop down list in my combo box and my form will display all records with dates that are in January regardless of month or year.

View 4 Replies View Related

Searching By Date Doesn't Work

May 11, 2006

I have a table called tblorders for orders. So I have a form for this, frmOrders.

I also have a form to perform various searches on the orders. So I have a date textbox on this search form and a command button which I want to open the frmOrders according to the date I enter in the textbox. But even though the date on the search form matches the date in tblorders it does open the relevant record??!!

The date textbox is linked to the date field in the tblorders but it doesn't recognise it even if the date is correct! Everything is set to Format: Short date

Any ideas? This system works for other things like serial number etc but not the date for some reason.

Thanks.

View 5 Replies View Related

Queries :: Searching Date Before And Using This In WHERE Condition

Sep 13, 2013

I have a table that has 4 fields; id_vl, id_product, date_vl, vl.

Basically each product is valued either on a monthly, weekly or daily basis. I want to create a filter that is based on a text box that filters the dates from which one can look at the dates of valuation and the associated values.

The problem comes with the products valued on a weekly or monthly basis. For example, if I simply say [tblvl].[date_vl]>=Me.textbox, and me.textbox = 13/09/2013, yet the last value date for a weekly product was 09/09/2013, this record won't be included. Therefore I need to set the date of the previous record as the filter. This is my attempt but it doesnt work...

Code:
SELECT tblVL.Id_VL, tblVL.Id_Product, tblVL.Date_VL, tblVL.VL,

FROM tblVL
WHERE iif(tblvl.date_vl<>me.fees_start_date, [tblVL].Date_VL>=(SELECT
MAX(PrevDate.Date_VL)
FROM tblVL AS PrevDate WHERE PrevDate.Date_VL<[tblVL].[Date_VL] AND PrevDate.Id_Product=tblVL.Id_Product;),tblvl.date_vl>=Me.fees_start_date)
;

View 1 Replies View Related

Forms :: Start And End Date Text Boxes In Search Form?

Nov 7, 2014

I have a pair of captioned text boxes for taking the criteria for the search result. Currently the text boxes are tied with a date field. I would like to give the user's choice of a number of date fields. After some research, I believe option group control fits for this purpose. Unfortunately, I never try this function before.

View 1 Replies View Related

Modules & VBA :: Filtering Form With Search Box

Mar 21, 2014

I am using the following code to filter my form with a search box:

Code:
Me.RecordSource = "qryCompanies"
Me.Filter = "CompanyName Like '*" & Me.SearchTxt & "*' Or webpage Like '*" & Me.SearchTxt & "*' Or PriorName Like '*" & Me.SearchTxt & "*'"
Me.FilterOn = True

[Code] ....

It works great with one minor issue: if I try to search for a name containing an apostrophe, I get a syntax error. So, it won't find Children's Hospital for example.

View 4 Replies View Related

Select Statement Searching On Date Criteria

Feb 23, 2006

Hello everyone! :)

I've been banging my head of a brick wall with this one. Its probably straight forward... but I can't see the solution! A problem shared is a problem halved... or so they say!

Ok I have this table called CustomerComments. In it are the following columns

CustID
Comment
CommentDate

For each custID I want the most recent commentdate and its matching comment from that row... (there can be multilple comments recorded per custID)

Problem is I can't seem to get this to work.. instead its returning all rows. I have run a query that will sort and group this list. The top line of the grouping gives the most recent comment and commentdate per customer.

Does anyone know how I could just get that top line per custID rather than all rows returned?

Thanks for reading this... hope it makes sense!

:)

View 4 Replies View Related

Reports :: Searching Year On Date Time Value

Dec 28, 2013

i'm trying to filter is a datetime value and it just doesn't whant to work.I tried to make a separate unbound text field to filter out the Datetime into year and then filter that field out with year but it doesn't work. What I did:

-I clicked on the control element of the unbound text field.
-made a expression with this code : datepart ("YYYY", [BeginDatetime])
-(BeginDateTime is a table value)
-After this one it keeps showing me this error :
-"the syntax of the expression You've taken specified is invalid"

View 1 Replies View Related

Queries :: Searching If A Date Is Booked Or Not In A Query

Dec 2, 2014

I am currently working through my A2 (final year of high school in the UK) ICT coursework, in which I am building an Access database system for a small wedding car hire company.

My current problem is I would like to (not even sure if it's possible but I assume it is) have a form that searches a query for a date that the customer has entered.

If there is no date in the query that matches the one that the customer has entered, it means that their chosen date is available. If there is a match however it means that the date is unavailable.

I am using Microsoft Access 2010.

View 1 Replies View Related

Modules & VBA :: Set Datatype As Date / Time In The Form - Update Table With Null Date

Mar 12, 2014

I have a form with Date of Death (DOD) field. I would like update DOD from a table dbo_patient into Z_Patients table.

I have set the datatype as Date/Time in the form for Date of Death.

Code:
Private Sub Update_DOD()
Dim rcMain As New ADODB.Recordset, rcLocalDOD As New ADODB.Recordset
Dim DOD As String
rcMain.Open "select distinct PatientKey from Z_Patients", CurrentProject.Connection

[Code] ....

However I am getting some error Run-time error '-2147217913 Date type mismatch in criteria expression in section below.

Code:
CurrentProject.Connection.Execute "update Z_MAIN_Processed_Patients set DateOfDeath = '" & rcLocalDOD!date_of_death & "' where PatientKey = " & !PatientKey

View 5 Replies View Related

Modules & VBA :: Open PDF From Form With Search Parameter

Sep 10, 2014

I have searched for bits of code to copy other people better than I, and had some success but I am failing to complete, so it is now time for me to visit you all. I am trying to open a PDF from a button on a subform. The location of the PDF is specified in a field. I want to open the PDF and search for a Member ID criteria also listed in a field on the Form.This is my code:

Code:

Private Sub Text12_Click()
Dim strPath As String
Dim Searchmem As String
strPath = [Notetxt]
Searchmem = [MemID]

[code]....

Adobe Reader reports "There was an error opening this document. The file cannot be found." but then opens the file (that's something).So it's the "search" bit that is the problem, and I cannot for the life of me get my search parameter to be used.

View 5 Replies View Related

Modules & VBA :: Inactive Use Of Null In Search Form

Mar 18, 2014

I'm trying to add a new functionality on my search form where the user can search for records that haven't been modified(based on the field DateModified) for certain amount of time.This is what I added in my search function but it's giving me "Invalid use of Null"

If Not IsNull(Me.txtInactiveTime) Then
Dim LValue As Integer
LValue = DateDiff("d", Me.DateModified, Date)
Select Case Me.txtInactiveTime
Case "> 1 month"
strWhere = strWhere & "(LValue >= " 30 ") AND "
Case "> 2 months"
strWhere = strWhere & "(LValue >= " 60 ") AND "
End Select
End If

txtInactiveTime is a combo box where the user chooses the time during which the records haven't been modified.(i.e. 1 month, 2 months etc.)

View 3 Replies View Related

Modules & VBA :: Search And Validate For Login Form

Nov 27, 2014

I have a table called 'Klanten' which contains the rows 'password' and 'login' (and several rows not needed for this form)

So I'm trying to make a login form which first checks if something is entered (this part of the code seems to work).

Private Sub Knop13_Click()
'Check to see if data is entered into Username
If IsNull(Me.Username) Or Me.Username = "" Then
MsgBox "gelieve een login in te voeren.", vbOKOnly, "Required Data"
Me.Username.SetFocus

[Code] ....

But from then on i seem to have some issues.. The part of the code underneath seems to only work for the first 'login' and 'paswoord' in my table called "Klanten".

-Username is the name for the field where they enter their 'login'.
-Password is the name for the field where they enter their 'paswoord'

If Username.Value <> DLookup("[login]", "Klanten", "[Username]='" & Username & "'") Then
MsgBox "Invalid Username. Please try again.", vbOKOnly, "Invalid Entry!"
Exit Sub
End If

If Password.Value <> DLookup("[wachtwoord]", "Klanten", "[Password]='" & Password & "'") Then
MsgBox "Invalid Password. Please try again.", vbOKOnly, "Invalid Entry!"
Exit Sub
End If

Then as last part i would like to goto another form called 'Mainmenu' if both the Login and the Paswoord is correctly entered in the fields Username and Password. Here i have the most issues as this doesn't seem to do anything at the moment

If Password.Value = DLookup("[wachtwoord]", "Klanten", "[Username]='" & Username & "'") And Username.Value <> DLookup("[login]", "Klanten", "[Password]='" & Password & "'") Then DoCmd.OpenForm "Mainmenu"
End Sub

View 1 Replies View Related

Modules & VBA :: Search Function In Locked Form?

Dec 2, 2013

I have a form that I allow my users to view but not to change any of the records.

As the number of records has grown it's become necessary to add a search function.

My problem is that because the form is locked it cannot be searched.

View 7 Replies View Related

Modules & VBA :: Access Implementing Search Button To A Form?

Oct 24, 2013

In my database I've encountered a hitch - I've got one form set up to view one person at a time and I've got many records in this database - Is it possible to create a textbox and a button called search that will take me to the record containing this text?

i.e currently im on record abc i type into the text dfe and press search - it will take me to a record that contains that text?

View 1 Replies View Related

Modules & VBA :: Continuous Form Combobox Search As You Type

Jul 28, 2014

What i want is to have a combo box on a continuous form that as you type it filters the Query it is based on using a Like *. and drops downs so the user can see the updated list after each key press? Is this possible?

View 4 Replies View Related

Modules & VBA :: Search Form Will Not Return Exact With Wildcard SQL

Jul 4, 2014

I did export the table data into a tabbed delimited format and will include that at the end. If you want to reproduce my bug copy that data in a txt file and import that into the table tblMain. Make a search form and a sub form. the sub form is linked to the table and the main form is unbound with two search buttons.

Problem Statement:The code works fine. I did find a bug that seems to arise with the wild cards when the entire field values are entered. You can replicate the bug by testing the search criteria listed below.

This is a brief example of the bug. A detailed description is near the code below.

If my name is "Devtycoon" and I search "Dev" the SQL statement will build "*Dev*" and it will pull up my name, "Devtycoon". On the contrary if I search "Tycoon" the SQL statement will build "*tycoon*" and it will pull up my name, "Devtycoon". If i search "DevTycoon" the sql statement will build "*Devtycoon*" and no results will be returned. That is buggy because the name is in the database but no wildcards would be needed.

Table structure:

tblMain
ClientID
Surname [text]
Organization [text]
ProgramTitle [text]
City [text]
State[text]
Zip4 [text]
Telephone [text]

Form1 contains the controls for search criteria. Three text box controls are used to filter a sub form control called "DS". The sub form is called sFrmMain and is a datasheet that shows results of the search. there is a button that runs the code and another button that clears search criteria and shows all records. Both button's code set the sub form's record source using an SQL string built using a function that returns a segment of the overall search string using the contents of each control that then is concatenated into a SQL statement used to set the record source.

There is a function for the following components of the SQL statement

SELECT / FROM
WHERE
controlA = me.txtSurname
controlB = me.txtOrganization
controlC = me.txtProgramTitle
This is how you can replicate the bug.

I tested two additional surnames organizations and program titles as follows:

Try example (1). you will get both the 4's and the 14's records returned.

If you type in letter for letter of the second record (the one with the 14's) no records populate. It is like the wild card does not like it if you type in the entire field value. Uncle Gizmo's and Allen Brown's method do the same thing were no records populate if the 14's entire surname organization and program title are entered into the text controls. Can you reproduce this error? Other than that I think either method is bulletproof.

Example criteria

1) put the following criteria in each control then hit the search button

4 surname
4 organization
4 program title
[two records returned]

2) put the following criteria in each control then hit the search button

[no records returned]
14 surname 14
14 organization 14
14 program title 14

Code behind search form:

Code:
Option Compare Database
Option Explicit
Private Sub cmdShowallRecords_Click()
Dim strSQL0 As String
Me.txtOrganization = ""
Me.txtProgramTitle = ""
Me.txtSurName = ""
strSQL0 = fSQL_SelectFrom & fWhere & fSurName & fOrganization & fProgramTitle
Me.DS.Form.RecordSource = Left(strSQL0, Len(strSQL0) - 5) & ")"

[code]....

View 12 Replies View Related

Modules & VBA :: Searching For Partial Primary Key?

Jan 8, 2014

I am trying to search for a partial number in the primary key field. I have based my search off Allen Browne's search form [URL]

I have posted my full code below. I am having trouble with the portion searching the Member_ID field.

My first version:

I would get a Run-time error '3464':

Data type mismatch in criteria expression.

Code:
If Not IsNull(Me.txtMember_ID) Then
strWhere = strWhere & "([Member_ID] = """ & Me.txtMember_ID & """) AND "
End If

My second Version: (I was searching for 54)

I would get a Run-time error '3075'

Syntax error (missing operator) in query expression '([Member_ID] = Like "*54*")'

Code:
If Not IsNull(Me.txtMember_ID) Then
strWhere = strWhere & "([Member_ID] = Like ""*" & Me.txtMember_ID & "*"") AND "
End If

Version 3:

If I use this the search works when the Member_ID matches exactly

Code:
If Not IsNull(Me.txtMember_ID) Then
strWhere = strWhere & "([Member_ID] = " & Me.txtMember_ID & ") AND "
End If

Code:
Private Sub Member_Search_Click()
'Purpose: Build up the criteria string form the non-blank search boxes, and apply to the form's Filter.
'Notes: 1. We tack " AND " on the end of each condition so you can easily add more search boxes; _
we remove the trailing " AND " at the end.
' 2. The date range works like this: _
Both dates = only dates between (both inclusive. _
Start date only = all dates from this one onwards; _
End date only = all dates up to (and including this one).

[code]....

View 14 Replies View Related







Copyrights 2005-15 www.BigResource.com, All rights reserved