Optional Selection In Query

May 12, 2006

I have two drop-downs on a form along with a child form that shows data based on a query. If both drop downs have selections, say date and dept. then the query would change and the child would show the data - that works fine, but what if one of the drop downs didn't have a value selected, as in i select a date but just want all departments so select noting from the second dd - how would i write the query to reflect this optional selection?

View Replies


ADVERTISEMENT

Modules & VBA :: Email Function Using Optional Parameters - Optional Argument Error

Aug 12, 2015

I keeping getting the error "Invalid use of Null" when i call my email function using optional parameters.

Code:
Email Me.ProjectID.Column(1), _
Me.ProjectAddress, _
Me.TaskDescID.Column(1), _
Me.TaskDescExt, _
strStatus, _
Me.TaskStatusID.Column(1), _

[Code] .....

View 4 Replies View Related

Using Optional Criteria For A Subform Query

Sep 4, 2005

Hi,

Is there a simple way to add optional criteria in a query for a subform? Basically, what I'm trying to do is have a number of comboboxes in the parent form that indicate what records are shown in the subform (these records could then be added and/or deleted). I would like to be able to have a combobox such as "Month" that would filter the data shown in the subform to that month. If no month is selected, then the subform would show all months.

Any help would be much appreciated.

View 2 Replies View Related

Making Criteria Optional

May 7, 2007

I have a form with an option group that depending on which one is selected, opens a report with a specific query as it's source. Part of the query looks at a listbox on the form. Here is the criteria for a field: [Forms]![frmOnSearch]![tboCollDev]
I want to make this criteria OPTIONAL. So if there is nothing selected in the listbox, the query should not look at that criteria. FYI, the value that is returned from the listbox is numeric.

Thanks
ScrmingWhisprs

View 2 Replies View Related

Multiple Optional Criteria

Oct 1, 2006

I've had a look around this forum and haven't seen anything really matching my needs, but please feel free to point me in the right direction.

What I am trying to do (using macros & queries - very new to SQL / VBA) is filter by multiple fields, but also allow the user to choose to filter by different combinations of fields - such as searching for first name and suburb, or salesperson and customer source, or first name and salesperson, or suburb and customer source, or three options or one, etc etc.

There will only be a certain number of search fields, probably five or six, but how do I get the query to recognise that if one of the search boxes is blank, it should allow all records in that field and only search by the other criteria, but if all the search boxes are filled in, the results must match all the criteria?

Does this make any sense?

PS - I am planning to use a command button as an "Apply Filter" so that the filter only updates after the user has specified all the options they want.

View 1 Replies View Related

Optional (multiple) Calendar Criteria

May 10, 2006

I am using this criteria with my calender on my form...

>=([Forms]![frmReport]![txtFrom]) And <=([Forms]![frmReport]![txtTo])

but I have 2 other date fields that I would like to query, so how do I go about making this optional?

Normally with a simple reference like:

Like([Forms]![frmReport]![txtFrom]) & "*"

with the form control's default value as * I tried working with that configuration but either it is not possible or I have the wrong syntax.

I'm open to a VB solution if anyone has one?

Note: I would only be using one of the date fields at any given time

thanks

View 2 Replies View Related

Reports :: Optional Footers On A Report?

Nov 19, 2014

Is it possible to have three different report footers on the same report? I want to show one footer at a time depending on a condition met in the detail section. I already know how to check the condition but I need to know how to do the rest.

Ex:
if condition1 = A then
me!reportfooter_1.visible = true
me!reportfooter_2.visible = false
me!reportfooter_3.visible = false
end if

View 7 Replies View Related

Modules & VBA :: INSERT With Optional Fields?

Jun 5, 2013

I currently have a bound form that adds a new student, however, I've decided I don't like bound forms as weird stuff can happen (like when the user exits in another way than I anticipated) so I'm making an unbound form which will add the student when a button is clicked. I already have this working on some other places so this should be no problem anymore.

However in my database a lot of student information is optional and only a first and last name are required (and ofcourse an autogenerated PK). So my question is how do I deal with these fields that might or might not be empty?

I could make a fairly big If ... ElseIf... construction where I slowly fill a String with all the optional fields but I was wondering if maybe there are some better ways to approach this?

View 12 Replies View Related

Queries :: Third Combo Box On A Form To Be Optional

Feb 24, 2015

How to get a third combo box on a form to be optional.

I have a form with two combo boxes which filter out the results on a query.

However I want the third combo box to be optional i.e. if it is blank then just the results of the first two combo boxes are shown. If the user selects all combo boxes then obviously the results are based on all combo box selections.

View 7 Replies View Related

General :: Argument Not Optional For Field

Apr 24, 2015

I have a subform and when you double click on any field it remembers 3 fields from the record you are in and stores them. I have 3 fields called [section], [losthrs], [stdhrs]. It works perfectly and stores the data from [losthrs] and [stdhrs] fields, but throws up "Argument not optional" for the [section] field.... Can not see a reason why, it is just a simple text field...

I have even tried 'pausing the code' and using the immediate window to show the field values, again losthrs and stdhrs are fine, section gives "Argument not optional".

View 4 Replies View Related

Compile Error - Argument Not Optional

Jul 30, 2015

Windows XP
Access 2007

I have followed Martin Green's steps (fontstuff) for creating an audit trail and am getting a compile error when I check my code.

This is my code and the error highlights 'Call AuditChanges' as the problem.

Private Sub Form_BeforeUpdate(Cancel As Integer)
If Not Me.NewRecord Then
Call AuditChanges("ImprovementID")
End Sub

View 5 Replies View Related

Forms :: Optional Search Criteria For Users

Feb 27, 2014

On the access form I have designed , I need to give optional search option to the users. I have the following search options on the form (screenshot attached):

From Date
To Date
Port
Vessel
Voyage
---------------------

The query is as follows:

SELECT dbo_VESSEL.VESSEL_NAME, dbo_VESSEL.VESSEL_CD, dbo_VESSEL.VOYAGE_NUM, dbo_VESSEL.PORT_CD, dbo_VESSEL.DEPART_ACTUAL_DT, dbo_VESSEL.DIVISION_CD
FROM dbo_VESSEL
WHERE (
(dbo_VESSEL.VESSEL_CD Like [Forms]![VESSDAT].[Form]![txtvessel]) OR
(dbo_VESSEL.VOYAGE_NUM Like [Forms]![VESSDAT].[Form]![txtvoyage]) OR
(dbo_VESSEL.PORT_CD Like [Forms]![VESSDAT].[Form]![txtport]) OR
(dbo_VESSEL.DEPART_ACTUAL_DT BETWEEN [Forms]![VESSDAT].[Form]![txtfromdept] And [Forms]![VESSDAT].[Form]![txttodept]));
----------------------

However, the form still prompts me to enter values for all the boxes and still doesnt show the correct data.

View 14 Replies View Related

Modules & VBA :: Function - Can A String Be Optional Variable?

Aug 26, 2014

I am amending some Code I found online for an audit table, I need to store additional information in the table that is associated with some forms but not others.

I have researched about putting optional variables in, but I read this only works with the type VARIANT.

Is there a way to make a string optional as my fields contain text?

here is my code so far:

Sub AuditChanges(IDField As String, UserAction As String, Optional UserID As String, Optional DeviceID As String, Optional SimID As String)
On Error GoTo AuditChanges_Err
Dim cnn As ADODB.Connection
Dim rst As ADODB.Recordset
Dim ctl As Control
Dim datTimeCheck As Date

[Code]...

View 5 Replies View Related

Forms :: Calculation In A Field - Getting Argument Not Optional Error

Sep 18, 2014

Trying to create a calculation in a field (text25) that excludes weekends and holidays. I am getting an argument not optional error.

Code : Me.[Text25] = GetBusinessDay([Due_Date - Result_Date])

View 14 Replies View Related

Forms :: Search / Filter By Multiple (optional) Textboxes On Form

Aug 1, 2013

I'm relatively new to MS Access (using MS Access 2013 but the db should work on 2010, too) and try to develop a database for an NGO I'm working in. I created almost all the tables (all that I need for now) and made the relationships.

However now I start to create forms and later reports for the actual user. The database will store information about clients and track consultations and assistance the NGO gives to them. There will be around 50.000 to 70.000 clients in the main table. Every client has a specific Individual ID and is member of a family which itself has another specific Group ID.

Now here is my problem: The User usually searches for the respective family by the Group ID. I implemented this with a search query using the ID number of a search text box. All done and no big problem.

But sometimes the ID number is not known so the user needs to search by name (First and Last Name). I use to different textboxes for this and it works in a similar way like the number search by query (Like "*" & [Forms]![frm_SearchIC]![txt_LName] & "*"). All still good However since most of the clients are actually from arabic speaking countries, converting the names into the Latin alphabet is bound to fail and produce a lot of misspellings. Therefore I added 2 more textboxes and 3 comboboxes for the user to give more information about the client and therefore make it easier to search for the person. I was able to produce a query which gives you the right result if you have ALL information at hand. However, this is not always the case.

1) But I cannot find a way to tell the query that if the a certain textbox or combobox is empty, it shall just "ignore" it and use the information at hand. I tried this in the query by adding in the criteria OR .... Is Null. This is alright for one or two textboxes but for the many I have, it seems to be too many different combinations for the criteria. It just worked with some fields but others always had to be filled in...

2) If no information is given at all, the database should inform the user that he needs to enter at least on field. If nothing is found the user should get a msgBox saying "No IC matches your criteria".

3) The results of the searches should be given out in another form where the user can pick the person from 1-to-many results.

I attached a sample database with sample data and reduced tables, fields, and entries ...

View 6 Replies View Related

Forms :: Email Using User Selected HTML Template With Optional Report As Attachment

Jun 27, 2015

I have an access form. It has

-Two textboxes with client first and last name
-Two textboxes with a contact 'email1' and 'email2' for the client
-A combobox with a list of templates to use for the email.
-A checkbox to include a copy of the statement on the email.

I want the user to be able to press a button which does the following

-Sends an email to both 'email1' and 'email2'.
-Attaches a secific report as PDF if the user has selected the checkbox
-The body of the email includes a greeting line using the clients name from the record.
-The body of the message includes below the greeting line a html email template depending on the users combobox selection.

View 3 Replies View Related

Forms :: Nomination Form - Combobox Selection List Not Updating After Each Selection

Oct 27, 2014

I am designing a nomination form (web database so no vba macros can be used).

The form has 3 combo boxes: cboStaffName, cboLevel, cboNominee.

The form is bound to the tblSubmit table where the submissions are populated.

I used a select statement:SELECT Staff_List.Staff_Name FROM Staff_List; to populate the combo box for the Staff Name selection.

This is the select statement to populate the job level combobox:

SELECT Staff_List.Level, Staff_List.Staff_Name FROM Staff_List WHERE (((Staff_List.Staff_Name)=[forms]![frmtest]![cboStaffName]));

The select statement to populate the combobox for the nominee combobox:

SELECT Staff_List.Staff_Name FROM Staff_List WHERE (((Staff_List.Level)=[forms]![frmtest]![cboLevel]));

The problem is that the staff_name in the first combobox is still found in the nominee combobox which should not be because a staff cannot nominate self. There is a field in the Staff_List called YesNo that should be activated for each staff that is selected so that the select statement on the nominee combobox can be updated accordingly to remove items with the field "Active"

How to get the checkbox selected for each corresponding staff.

Sample of the database has been attached.

View 4 Replies View Related

Query W/selection

Mar 30, 2008

I've got a query; works great as written; but I need to be able to have users choose which month to pull data for.
Right now; I pull the current month data using:

Between DateSerial(Year(Date()),Month(Date()),1) And DateSerial(Year(Date()),Month(Date())+1,0)

Is there a way I can rewrite this but use a user-selectable date for the month? I'm thinking it could be done w/two queries; but not sure about just one....

Thx

View 14 Replies View Related

Forms :: Setting Text Box Format To Short Date And Optional Short Time

Jun 21, 2013

I want to be able to set text boxes so that if one enters a date and a time it displays in the format "dd/mm/yyyy hh:mm", but if one just enters a date is displays in the format "dd/mm/yyyy". Is this possible?

Stipulating "dd/mm/yyyy hh:mm" means that when you just enter a date it adds "0" values for the time e.g. entering "21/6/13" gives "21/06/2013 00:00".

General Date allows for an optional time, but it means that when you do enter a time it gives you seconds as well "dd/mm/yyyy hh:mm:ss" - and I don't want that.

View 7 Replies View Related

Selection Query To Form

Jun 7, 2006

I wonder if anyone can help with this:

I have put a selection query as a subform in a form which shows client details. When the form opens from the switchboard it asks the user to enter the clients unique number and then the query links the number to the client ID (autonumber) which then populates the form with all the details for that client. This is all great but I have 2 questions?

1. If I put in an incorrect number or press cancel the form loads anyway with no record. Is there a way to force the user to re-enter the number or if the number does not exist say so, and then return to the switchboard. The aim of this form is for reference and not data entry anyway.

2. Once in the form correctly is there a way to 'refresh' the form so that it asks for the card number again. My plan is to have a button "search for another client" and when it is pressed the query runs again and the input box comes up.

Cheers

View 1 Replies View Related

Combo Box Selection For Query

Feb 13, 2006

I'm new at Access 03. I have a combobox that is sourced by a table, Rowsource property is:

SELECT Classes.TableID, Classes.ClassID FROM Classes;

The name of my combobox is "ClassCombo".

I'm trying to generate a report based on my combobox selection, but I can't reference the value of the selection. The query tied to my report has the following SQL:

SELECT ClassesForInstructors.ClassID, Instructors.InstructorID, Instructors.FirstName, Instructors.LastName
FROM Instructors INNER JOIN ClassesForInstructors ON Instructors.InstructorID = ClassesForInstructors.InstructorID
WHERE (((ClassesForInstructors.ClassID)="[Forms]![School]![ClassCombo]"));

I'm trying to grab the "ClassCombo" value as input to my query, but it's not working. What am I doing wrong?

Thanks!

View 2 Replies View Related

Query Job Id Selection Vis Text Box Input

Jun 29, 2006

I am trying to produce a query that will search for multiple records by job id entered into a text box eg 17656,18768,15679.

The example i have found uses the (LIKE '*value*') so if i type in part of a job id (176) it will display all records starting with 176. I would like to enter specific job id numbers seperated by a , and only display these

Would be grateful for any help

View 2 Replies View Related

Multiple Selection In A Query From A Form

Aug 1, 2006

Dear All

I've got an issue with a query/form combination that I'm working on. I have the following:

A query where one of the the fields is 'Name' (a text field). 'Name' can be one of 6 different values. I have a form which has 6 check boxes, one for each name. I'm using check boxes on the form rather than a multiple selection list box simply because I think it looks better.

When the user has checked one or more of the check boxes and hits the 'show results' button, I want the query to open up with the details for orders associated with the name(s) selected.

I am writing my query in 'design view' rather than in 'SQL view', and don't know what to put in the criteria box of the 'Name' field. Depending on which check boxes are checked, I'm building a string and storing it in a text box, called Text1. I think the best way to do the filter is to use the In operator, and I currently have a structure like this in the criteria of the query: In([Forms]![Form1]![Text1]). This, however, doesn't give any results.

The problem I have, therefore, is that I don't know the correct syntax for the text within Text1. If I have, for example "Rob","Dave" as the text in Text1, it doesn't work, but if I put In("Rob","Dave") in the criteria rather than referencing the text box, it works fine.

Do anyone know what I'm doing wrong?

View 1 Replies View Related

Query By Multiple Selection List Box

Jul 24, 2007

so i have two listboxes that have the values i want for the query parameters. I slightly modified one code i found so that i can query using one of them, however i cannot figure out how to get the second listbox to put criteria into another field. The working code i'm using is:

Private Sub Command_Click()
On Error GoTo Err_Command_Click

On Error GoTo Err_Handler
Dim varItem As Variant
Dim strCriteria As String
Dim strSQL As String


For Each varItem In Me.PartyBox.ItemsSelected
strCriteria = strCriteria & "counterparties.counterparty =" & Chr(34) & Me.PartyBox.ItemData(varItem) & Chr(34) & " Or "
Next varItem


strCriteria = Left(strCriteria, Len(strCriteria) - 4)

strSQL = "SELECT counterparties.[Counterparty Entity], Fund.[Fund Name], products.Product, combine.[Available?] " & _
"FROM products INNER JOIN (Fund INNER JOIN (counterparties INNER JOIN combine ON counterparties.[Counterparty ID] = combine.[company id]) ON Fund.[Fund ID] = combine.[fund id]) ON products.[Product ID] = combine.[product id] " & _
"WHERE " & strCriteria


CurrentDb.QueryDefs("1").SQL = strSQL


DoCmd.OpenQuery "1"

Exit_Handler:
Exit Sub

Err_Handler:
If Err.Number = 5 Then
MsgBox "Must Make A Selection First", , "Make A Selection First"
Exit Sub
Else
MsgBox Err.Number & " " & Err.Description
Resume Exit_Handler
End If


Dim stDocName As String
stDocName = "combqry"
DoCmd.OpenQuery stDocName, acNormal, acEdit

Exit_Command_Click:
Exit Sub

Err_Command_Click:
MsgBox Err.Description
Resume Exit_Command_Click

End Sub



I am trying to be able to search by Product and counterparty.
Any help is greatly appreciated, thanks!

View 8 Replies View Related

Running A Query By A Selection From A Combo Box

Dec 10, 2007

I have a query that runs info selected from safety visits. I have made a form with an unbound combobox that selects the supervisors name and after the name is selected, I have a button to run the query. When a name is selected, the query comes up blank. When I do not select the name, the query is populated.

My criteria on the query is [forms]![personnel]![combo9]

Combo9 is the unbound dropdown menu with the supervisors name that is taken from a table of names.

Any help?

Thanks in advance.:(

View 1 Replies View Related

Using A Combo Box Selection For Query Criteria

Nov 1, 2006

I have a report that is based on a query. In the query, I have a field called "Mode". In the criteria section for the Mode field, I am calling the selection from a combo box on a form called "frm_main". So the criteria for the Mode field is "[Forms]![frm_Main]![Mode_ComboBox]". This combo box has selections for 1,2,3,4,5. I want a selecton on the combo box that will work with the query to show all modes. Sometimes something weird gets entered into the database like "NoMode" for example. I have tried adding a combo box selection of "*" , "Is Not Null" and "". If I manually type these into the criteria section of the query, it works fine. But when I use these in the combo box and call the combo box selection from the query, it does not work.

Does anyone have any idea what I can use in my combo box selection that when selected, the query (and hense report) will show all data?

Thanks,
Jim

View 5 Replies View Related







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