Solved

Get a value from Table, check if fields are -1

Posted on 2016-10-31
1
24 Views
Last Modified: 2016-10-31
hello,

I want to build a SQL that will check the table based on a "permit #" then if within that it finds that 4 fields are -1 then deny using that permit#

OK, so on my form I have the field:  txtPermit

on the beforeupdate, or even the afterUpdate,  I want it to search the txtPermit field in a table:  tblHWWPass, pull 4 fields and check to see if those all have "-1" (they are checkboxes)

txtPermit:  1

my sql will be

("Permit", "tblHWWPass", me.txtPermit)

but I don't know how to see if
Tab1
Tab2
Tab3
Tab4

are all -1

?
0
Comment
Question by:Ernest Grogg
1 Comment
 
LVL 119

Accepted Solution

by:
Rey Obrero earned 500 total points
Comment Utility
use the dcount to check the presence of the record that satisfy the criteria in the beforeupdate event of the form

private sub form_beforeUpdate(cancel as integer)
' if Permit is Number Data type use this
if dcount("*","tblHWWPass", "[Permit]=" & me.txtPermit & " and [tab1]=-1 and [tab2]=-1 and [tab3]=-1 and [tab4]=-1") >0 then

' if Permit is Text Data type use this
'if dcount("*","tblHWWPass", "[Permit]='" & me.txtPermit & "' and [tab1]=-1 and [tab2]=-1 and [tab3]=-1 and [tab4]=-1") >0 then


 msgbox "record already exists"
 cancel=true

end if

end sub
0

Featured Post

How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

Join & Write a Comment

Most if not all databases provide tools to filter data; even simple mail-merge programs might offer basic filtering capabilities. This is so important that, although Access has many built-in features to help the user in this task, developers often n…
Introduction When developing Access applications, often we need to know whether an object exists.  This article presents a quick and reliable routine to determine if an object exists without that object being opened. If you wanted to inspect/ite…
In Microsoft Access, learn how to use Dlookup and other domain aggregate functions and one method of specifying a string value within a string. Specify the first argument, which is the expression to be returned: Specify the second argument, which …
Access reports are powerful and flexible. Learn how to create a query and then a grouped report using the wizard. Modify the report design after the wizard is done to make it look better. There will be another video to explain how to put the final p…

744 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

17 Experts available now in Live!

Get 1:1 Help Now