Free Lessons
Fast Tips
Topic Index
Home   Courses   Templates   Seminars   TechHelp   Forums   Help   Contact   Join   Order   Logon  
Access Q&A: Criteria, Numbering
By Richard Rost   Richard Rost on LinkedIn Email Richard Rost   16 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.

Comments for Access Q&A: Criteria, Numbering
Age Subject From
15 yearsNo SubjectRichard Rost
15 yearsNo SubjectHenry Guttman


Start a NEW Conversation
Only students may post on this page. Click here for more information on how you can set up an account. If you are a student, please Log On first. Non-students may only post in the Visitor Forum.
Subscribe to Access Q&A: Criteria, Numbering
Get notifications when this page is updated

The following is a paid advertisement
Computer Learning Zone is not responsible for any content shown or offers made by these ads.

Access - index
Excel - index
Word - index
Windows - index
PowerPoint - index
Photoshop - index
Visual Basic - index
ASP - index
My Account
My Courses
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
Mailing Address
Phone Number
Fax Number
Course Survey
Email Richard
[email protected]
Blog RSS Feed    YouTube Channel

Copyright 2023 by Computer Learning Zone, Amicron, and Richard Rost. All Rights Reserved. Current Time: 12/4/2023 10:41:07 PM.
Keywords: access textbox criteria round tips  PermaLink  Access Q&A: Criteria, Numbering