?
Solved

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

Posted on 2016-10-31
1
Medium Priority
?
47 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
1 Comment
 
LVL 120

Accepted Solution

by:
Rey Obrero (Capricorn1) earned 2000 total points
ID: 41867646
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

Comprehensive Backup Solutions for Microsoft

Acronis protects the complete Microsoft technology stack: Windows Server, Windows PC, laptop and Surface data; Microsoft business applications; Microsoft Hyper-V; Azure VMs; Microsoft Windows Server 2016; Microsoft Exchange 2016 and SQL Server 2016.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

In earlier versions of Windows (XP and before), you could drag a database to the taskbar, where it would appear as a taskbar icon to open that database.  This article shows how to recreate this functionality in Windows 7 through 10.
Access custom database properties are useful for storing miscellaneous bits of information in a format that persists through database closing and reopening.  This article shows how to create and use them.
In Microsoft Access, learn how to “cascade” or have the displayed data of one combo control depend upon what’s entered in another. Base the dependent combo on a query for its row source: Add a reference to the first combo on the form as criteria i…
In Microsoft Access, learn different ways of passing a string value within a string argument. Also learn what a “Type Mis-match” error is about.
Suggested Courses

752 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