Access 2007-2019
Access 2000-2003
Access Seminars
TechHelp Support
Tips & Tricks
Access Forum
Course Index
Topic Glossary
Insider Circle
Home   Courses   Seminars   Templates   Help   TechHelp   Forums   Contact   Join   Order   Logon  
Access Q&A: Criteria, Numbering
By Richard Rost   Richard Rost on Twitter Richard Rost on LinkedIn Email Richard Rost   14 years ago

Here are some more Access questions I've answered recently. If you want to submit one, visit my TechHelp page.

I have a form with three text boxes:
Proposal ID #
Office Name
Division Name

Goal: I would like to run a query so if the user fills in only one of the three textboxes (the other two are left blank) the query responds using that one textbox as a parameter. In addition, if the user does not use any of the textboxes I would like all records to show.

Currently: My query uses this criteria for the proposal ID#:
Like [Forms]![ProjectProposalBasics].[ProposalID]
I thought if I place the same criteria statement for Office Name:
Like [Forms]![ProjectProposalBasics].[OfficeName] in the OfficeName "OR" section of the query I would have my solution. Instead I get nothing. I am using the MS Access design query not SQL in VBA.

How do I make this work?

I would make a fourth, invisible text box. In the command button that fires your query, use some VBA code to set the value of your fourth box equal to the criteria you want.

If Not Isnull(ProposalID) Then
MyCriteria = "Like [Forms]![FormName]![ProposalID]"
ElseIf Not Isnull(OfficeName) Then
MyCriteria = ...

Then when your query runs, just have it read the criteria from this new dynamic form field. Easy enough?

If you need help with the VBA code, I cover it in more detail in my Access 301 class.

Hi Richard
I have problem with the database im working i am inputting a number 2.5 and it automatically round off to 3. What expression should I code to be able not to round off the number. Hope you can help me.


Sounds to me like your table field is set to either INTEGER or LONG INTEGER. Change the field data type to DOUBLE, SINGLE, or DECIMAL and your problem should go away. If this is NOT the case, let me know.

I cover this topic in detail in my Access 101 and 102 tutorials.

I would like to number records based on their filter.
For example. If I add sessions to a class ID. I would like the sessions to number themselves from 1, 2, 3 etc based on their dates. Is this possible?

Anything is possible in Access, but I'd need to know more about exactly how you want to number them. I don't know exactly what you mean by "based on their filter."

If you just want to assign them numbers (1,2,3,etc.) as they're entered into a form, then you can just use a little bit of VB code in the BeforeInsert event for the form:

LargestNumber = DMAX("Session","MyTableT")
Session = LargestNumber + 1

That will basically look up the largest number in the field called Session in your table, and set the Session field on your current form to that value +1.

If that's all you need, there ya go! I cover VBA and topics like this in my Microsoft Access 301 tutorial. See my web site for details.

Upload Images   Link  
Richard Rost 
13 years ago
Henry, just set the criteria for your LastName field to:


That will show you all A* names, like Apple, Adams, and Anderson. Remember, I covered LIKE in Access 102.
Add a Reply
Upload Images   Link  
Henry Guttman 
13 years ago
Created a telephone book. Like to create a querie showing all last names that start with "A".Thank you for your prompt reply.

Add a Reply

Start a NEW Conversation
Only students may post right now. Click here for more information on how you can set up an account. If you are a student, please LOG ON first.

You may want to read these articles from the 599CD News:

12/3/2021Access Beginner 2
12/3/2021Access Beginner 2 Lessons
12/3/2021Access Beginner 2
11/30/2021Import Multiline Cells
11/30/2021Adam's Access Games
11/29/2021Prevent Close
11/22/2021Currency Symbols
11/13/2021Access Developer 36
11/13/2021Access Developer 36 Lessons

Access - index
Excel - index
Word - index
Windows - index
PowerPoint - index
Photoshop - index
Visual Basic - index
ASP - index
Account Login
Online Theater
Lost Password
Student Databases
Change Email
Latest News
New Releases
User Forums
Topic Glossary
Tips & Tricks
Search The Site
Code Vault
Collapse Menus
Customer Support
Web Site Tour
Consulting Services
Affiliate Program
Richard Rost
Free Lessons
Mailing List
Video Tutorials
Learning Connection
Idiot's Guide to Excel
Volume Discounts
Payment Info
Terms of Sale
Contact Info
Support Policy
Email Richard
Mailing Address
Phone Number
Fax Number
Course Survey
Blog RSS Feed    Twitter

YouTube Channel    LinkedIn
Keywords: access textbox criteria round tips  PermaLink