Checking For Null In Multiple Fields
Oct 19, 2004
If I have about 9 Text fields, How would I go about checking to see if all of the text fields are empty, then hide all the fields, but if any of them have anything in it, show them all. Here is my code, but it doesn't work:
Code:If SpecAgent = "" And SpecArea = "" And SpecBenefit = "" And SpecCompany = "" And SpecCSR = "" And SpecDoctor = "" And SpecHospital = "" And SpecPlan = "" And SpecRx = "" ThentglNo = TruetglYes = FalselblSpecAgent.Visible = FalseSpecAgent.Visible = FalselblSpecArea.Visible = FalseSpecArea.Visible = FalselblSpecBenefit.Visible = FalseSpecBenefit.Visible = FalselblSpecCompany.Visible = FalseSpecCompany.Visible = FalselblSpecCSR.Visible = FalseSpecCSR.Visible = FalselblSpecDoctor.Visible = FalseSpecDoctor.Visible = FalselblSpecHospital.Visible = FalseSpecHospital.Visible = FalselblSpecPlan.Visible = FalseSpecPlan.Visible = FalselblSpecRx.Visible = FalseSpecRx.Visible = FalseElsetglNo = FalsetglYes = TruelblSpecAgent.Visible = TrueSpecAgent.Visible = TruelblSpecArea.Visible = TrueSpecArea.Visible = TruelblSpecBenefit.Visible = TrueSpecBenefit.Visible = TruelblSpecCompany.Visible = TrueSpecCompany.Visible = TruelblSpecCSR.Visible = TrueSpecCSR.Visible = TruelblSpecDoctor.Visible = TrueSpecDoctor.Visible = TruelblSpecHospital.Visible = TrueSpecHospital.Visible = TruelblSpecPlan.Visible = TrueSpecPlan.Visible = TruelblSpecRx.Visible = TrueSpecRx.Visible = TrueEnd IfEnd Sub
View Replies
ADVERTISEMENT
Aug 17, 2005
Hi all. I want to check for not null value constraint for all tables in database . I tried the following but when i run it i get the following error:
Compile error:
Invalid Next control variable reference
I be happy if some one one help me fix this error.if i remove the bold lines the program workes well but it does not put not null for table fileds that requries value.
picture of the output without the bold part
http://i5.photobucket.com/albums/y1...007/notnull.jpg
Code:Option Compare Database''This module displays field name and type in a massage boxFunction ShowFields(pTable As String) As StringDim db As DatabaseDim rs As RecordsetDim I As Integer''Dim j As IntegerDim n As Integer''Dim NL As StringDim strHold As String, ST As String''Dim x As Variant''NL = Chr(13) & Chr(10) ' Define newline.Set db = CurrentDbSet rs = db.OpenRecordset(pTable)n = rs.Fields.CountReDim x(n - 1, 1) As String'''ST = "Create Table " & pTable & vbCrLf''adding Create table and table name to statementST = "Create Table " & pTable & vbCrLf & "("For I = 0 To (n - 1)For Each fld In tbl.Fields ST = ST & rs.Fields(I).Name & " " & FieldType(rs.Fields(I).Type) & "," & vbCrLf If fld.Required = True Then ST = ST & " NOT NULL" & " " Else ST = ST End IfNext Irs.Closedb.CloseSet db = NothingShowFields = ST '' returns the fields name to main functionEnd Function
on click even code
Code: For Each T In db.TableDefs '''Skip the system tables If Left(T.Name, 4) <> "MSys" Then ''' this line determines the primary key of the table ''' by calling GetPk function from module pk = Left(GetPK(T, db), InStr(1, GetPK(T, db), "<-") - 1) cont = cont & ShowFields(T.Name) & vbCrLf & " primary key " & "(" & pk & ")" & vbCrLf & ")" & vbCrLf End If Next T ''' This line of code post the generated table statment to a massage box MsgBox cont
View 1 Replies
View Related
Aug 16, 2013
I have a form with mandatory fields highlighted a different colour (yellow or blue). On the form are 3 tab pages with subforms which also have these fields.
I have added a checkbox named incomplete to each tab page and to the form. My intention is to try to write some code to look at each field on the page and if the non-white (ie mandatory) fields all have a value, then the incomplete on that page is changed to no. The code then checks the incomplete value for all 3 pages - if these are all no and the form's mandatory fields are also filled in, then this also becomes no.
When creating reports, I can then find out which records have not been completed and notify the relevant staff. Also if the data is incomplete, they don't want those records appearing in reports - so I can use the incomplete value from the form.
View 4 Replies
View Related
Nov 17, 2011
I am creating a query to scrub out certain records from a table. How would I exclude records where BOTH the "Phone" and "Email" fields are null? I do not want to exclude them if "Phone" field is not null but the "Email" field is, or vice versa.
I currently have tried WHERE ((([RAWCancels]![Phone number] And [RAWCancels]![Email]) Is Not Null)), but it is not working.how to write the criteria.
View 13 Replies
View Related
May 30, 2007
I am trying to build an email string and have been sucessful...although there are times when the Email Field in my table may not have a value....
Currently this creates an error....I am trying to test for Null and then SKIP that record if it is null and move on...
Any thoughts?
THe problem is that I can click the Msgbox that gives me the varialbe from strTo endlessly....I am stuck in the loop...it never gets to EOF???
It never even gets passed the first record it finds...
Something is messed up....
Anyone have any thoughts...
?????????????????????
' START CODE ==================================
Dim dbs As Database
Dim rs As DAO.Recordset
Set dbs = CurrentDb
Set rs = dbs.OpenRecordset("Select * From tbl_Groups", dbOpenDynaset)
Dim strTO As String
Dim EmailString As String
strTO = ""
EmailString = ""
Do Until rs.EOF
strTO = rs!Email
If strTO = "" Then
MsgBox "NOTHING"
Else
MsgBox strTO
End If
Loop
DoCmd.SendObject acSendNoObject, , , EmailString, , , "Subject Line", , True
' END CODE ====================================
View 4 Replies
View Related
Jul 10, 2014
The following code doesn't check null condition in Scannedby field. The scannedby has text data type. The code gives me all the data where scandate=20130722 but doesn't check that scanned by can't be blank.
Code:
rs.Open "select count(*) from BatchTBL2 where scandate=20130722 and scannedby <> null", cn, adOpenKeyset, adLockOptimistic
j = rs.fields(0).Value
View 5 Replies
View Related
Oct 16, 2014
Me.Text11 = Nz(DAvg("[final whse-in diff]", "dbo_inventory", "[CAFETYPE]=" & Me.Text7 And "isnull(me.[DATE FIXED])=" & True And "isnull(me.DATE_IN)=" & True), 0)
I am getting a type mismatch error with this.
My question is:
1. is the syntax correct....
2. Is my way of checking for a value to be null correct....
View 4 Replies
View Related
May 30, 2014
I have been working on an application where I am collecting survey data in a database. There are multiple survey tools available to the user, and it's possible to complete multiple survey tools in the survey.My problem is, it's possible for the surveyor to complete some tools on one day and other tools on another day. I am having problems with trying to figure out how to add a tool that has not been previously added and keep in the same survey which is all held under a single Survey Number.
The first step in the function is to set a Record Number temporary variable based on whether or not the tool has been used (it's possible to use multiple instances of a survey tool, so need to know if the Record Number is '1', or the next number in the sequence.I've been trying to do this by checking a query for a Null and setting the temporary variable using something like:
IF ISNull("RecordNumber","qryRecordHeader") Then '1'
Else
DLast("RecordNumber","qryRecordHeader") +1
End IF
The second half works just fine, so if there is a previous record, it will add. But if it's Null, it doesn't work.I'm trying to avoid opening a temporary form to run the query and checking a field. Is there a way around that?
View 3 Replies
View Related
Jan 10, 2014
So on a command button I have this code in the OnClick event. When I click the button it will ask me to enter the name if blank but if I enter something in that field and then delete the data is bypasses this. Does the same reason field, Why?
Code:
If IsNull(Me.CE) Then
MsgBox "Please enter your name"
Me.CE.SetFocus
Exit Sub
[Code] ....
View 1 Replies
View Related
Oct 16, 2006
Question concerning how to check a value against multiple columns in Access with ASP.
Need help converting this to proper ASP and Access syntax
Code:myId = "test"myName = "monkey"SELECT * FROM table1 WHERE (programId1='" & myId & "' OR programId2='" & myId & "') AND (name1='" & myName & "' or name2='" & myName & "')"
is this doable with asp and Access?
If this helps explain it better, the following is how I would call it with PHP & mysql:
Code:$myId = "test";$myName = "monkey";SELECT * FROM table1 WHERE (programId1 = $myId OR programId2 = $myId) AND (name1=$myName OR name2=$myName)
Any help would be appreciated
View 2 Replies
View Related
Sep 27, 2005
Hi all,
I had a little problem with delete query. I would like to delete the records by checking two fields if both fields are empty. I mean if a records had both these fields are empty only. If one of the field has data , the record should stay there.. Is there any way I can do this?
Thanks in advance.
Thanks
View 4 Replies
View Related
Mar 10, 2005
Hi there,
I have several check boxes, that are however categorised, in my form. I was now wondering, in order to save some time, how could I make a check box that marks/unmarks all the boxes under that specific category ??
Cheers,
Pekka
View 1 Replies
View Related
Jun 15, 2013
I'm using Access 2013. I want to check duplicate data. I have a form where from insert data into table but before insertion I want check multiple criteria with form. How can I do this
Field are:
BatchID
BillNum
CIH
IH
back end form code is:
Private Sub cmdCheck_Click()
Dim criteria As String
criteria = "[BatchID]=" & Me.cboBatchID & " AND [BillNum]=" & Me.txtBillNum & " AND [CIH]=" & Me.txtCIH & " AND [IH]=" & Me.txtIH & ""
[Code] ....
Finally I'm getting this error: Run Time Error 3075 Syntax Error Missing Operator in qry Expr.
View 3 Replies
View Related
Mar 21, 2013
For my query I have 3 tables.
TEAMS. This contains TeamID / TeamName and TeamManagerName.
TeamAPPLinks. This is a many to many relationship and contains TeamAppID / AppID and TeamID (TeamID links to Teams.TeamID and AppID links to Applications/AppIS)
Applications. This contains AppID / AppName / Pass/Fail.
So teams can have many applications and applications can have many teams.
I only want to show teams that have all applications that have the Pass/Fail column as PASS. I have managed to do this for FAIL runing a query in a query but obviously its different for PASS as all associated applications have to be a PASS, not just one FAIL for a FAIL.
View 4 Replies
View Related
Jan 29, 2014
I am looking to check 3 sub forms for values and if they contain any then delete them. After a bit of googling I discovered that you should use recordset.recordcount - to which I tried but I get method or data not found - is this a valid method?
My code to which Im using is:
If Me.NoneChargeable_Admin_subform.Recordset.RecordCount >= 1 And Me.NoneChargeable_Manufact_subform.Recordset.RecordCount >= 1 And Me.NoneChargeable_Research_subform.Recordset.RecordCount >= 1 Then
DoCmd.RunSQL "DELETE NoneChargeable_Admin.*, NoneChargeable_Manufact.*, NoneChargeable_Research.* " & vbCrLf & _
"FROM NoneChargeable_Admin, NoneChargeable_Manufact, NoneChargeable_Research;"
End If
DoCmd.Close acForm, "NoneChargeableHrs_frm", acSaveNo
End Sub
View 1 Replies
View Related
Aug 25, 2014
I have a transaction form and there is at least two fields I need to make sure have been entered before the record is saved.
I have no problem with text or numeric fields but I can't seem to be able to check the contents of a drop down field.
What is the best method to use to make sure a drop down has been selected by the user and contains a value.
I have temporarily used a default value in the drop down but that's not really what I want.
View 3 Replies
View Related
Feb 25, 2015
Staff are monitored to make sure they are keeping up to date with our customers. A customer can have multiple projects going through the factory at any one time. Each customer has a record per project and a 'general' record. Ideally we would like our staff to be able to move the 'general' record when they update a project record as opposed to either having to find and then update the general record after, or forgetting and calling the customer again 2 days later!
Including a msgbox for the EnqNum seems to show the general record correctly, however being new to access I am unsure if I have the update part correct.
Code:
If Me.chkMoveGen.Value = "-1" Then
Dim EnqNum As Integer
EnqNum = DLookup("[e_id]", "tblEnquiries", "[c_id]=" & Me.txtc_id & " and [e_status] = " & "13")
DoCmd.RunSQL "UPDATE tblEnquiries " & _
" SET e_date_due=#" & Format(Me.txte_date_due, "MM/DD/YYYY") & "#" & _
" WHERE e_id= EnqNum"
View 3 Replies
View Related
Nov 29, 2013
I have a field 'Payment Types' with values (Cash, Cheque, Debit/Credit Card) and a field 'Payment Received' which is Yes/No.
When putting the order through the user selects the payment type and ticks a box if payment has been received.
On a report for delivery drivers, the owner wants it simple for the driver... he wants all the payment types listed with a checkbox next to each one, then wants the appropriate box ticked if payment has been received.
So I need something on the report (or underlying query) which ticks the appropriate box, i.e.
If payment received = true then payment type checkbox = true.
Or should I put the payments into a separate table with both fields so multiple payment types can be marked as paid?
View 6 Replies
View Related
Nov 21, 2013
how can i disable a textfield or two in a form when the textbox is unchecked also how do i add a default value for it while the textbox itself is disabled, can i get away with it by adding a default value on the textbox?
View 14 Replies
View Related
Jan 22, 2007
Hello, I am reposting a question submitted some time ago to which I did not get much help, hoping for additional advice.
My database has two tables. Table1 and Table2. Table2 is a copy of Table1. Both tables have 50 fields. Data is imported into Table1 once a week. Before importing data I run a delete query which removes all data. Data imported adds records only to the following fields: FNAME, LNAME, SSN. This means that I am left with 47 empty fields.
Users can see data in Table1 using Form1. They will see the FNAME, LNAME and SSN. These fields are locked and cannot be edit or deleted. All the other 47 fields are blank and user can add data to them.
Currently I am using two buttons to:
1) Close the form (with the code Me.Undo, Me. CLose)
2) Run and append query to Table2 and deleting all added data.
I would like to combine these two functions in one button which would:
If no data has been entered in the remaining 40 fields, than close the form.
If data has been entered it should run the following procedure (Append data into Table2):
Dim MyDb As DAO.Database, MyRs As DAO.Recordset
Dim strCode As String
Dim strFilter As String
Dim stDocName As String
Dim stLinkCriteria As String
Set MyDb = CurrentDb
Set MyRs = MyDb.OpenRecordset("Table1")
stDocName = "MyForm"
stLinkCriteria = "[SSN]=" & "'" & Me![SSN] & "'"
DoCmd.OpenForm stDocName, , , stLinkCriteria
DoCmd.SetWarnings False
DoCmd.OpenQuery ("AppendtoTable2")
DoCmd.Close
The problem I am having is declaring all the 47 empty records. Any suggestion or code? Thanks.
View 1 Replies
View Related
Jul 25, 2005
Does anyone know a nicer way of writing this. I basically want the form to quickly check all the fields to make sure they are filled in when the print button is clicked, different fields need to be filled in for different print buttons so i used this which works but seems very messy.
Private Sub Command0_Click()
If IsNull(reg) Then
MsgBox "You must enter Reg", vbCritical, "Data Required"
Else
If IsNull(make) Then
MsgBox "You must enter Make", vbCritical, "Data Required"
Else
If IsNull(model) Then
MsgBox "You must enter Model", vbCritical, "Data Required"
End If
End If
Exit Sub
End If
End Sub
View 2 Replies
View Related
Apr 26, 2006
Hi,
I have 2 tables... one with 'answers' (on questions) and one with these 'questions'.
Now I want to show the questions with their answers on a rapport
(based on a query) .. but only these whereby the answer-field is NOT NULL..
So I have already:
ansques1: IIf([answers.1] Is Null;Null;[questions.1]+" "+[questions.1])
But now if the answer-field is NULL, then the ansques-field is also NULL...
I want if the answer-field is NULL, to have no new field.. like ansques1.. just want to leave it out of the query... can someone help me with this?
Thanks in advance,
Ankie
View 2 Replies
View Related
Jun 8, 2005
I'm working on a db logging replies to a questionnaire. Judging by the responses I am receiving it appears that some sections are not completed at all. I need to be able to include these blank responses when it comes to analysis.
My design splits the questionnaire into sections, each section has a data entry form with its own underlying table. Each table has a primary key (autonumber field) which relates to each organisation that has replied.
If an organisation has failed to complete a section, I still need to create a new record in that section(table), triggering the autonumber field, hence referring back to the organisation.
I know I haven't explained this very well, but if anyone can make sense of what I'm saying and can give me any suggestions on how to make this happen, I would be most grateful.
In anticipation of your replies
Ride
View 4 Replies
View Related
Sep 12, 2013
I have a main form with multiple combo boxes that filter a subform datasheet. In my main form combo box [PR_Filter] I added a selection titled "<Blanks>". When I select "<Blanks>", I want it to filter my subform field [PR] for NULL values. If I select anything else I want it to filter on that selection. I cannot get the NULL filter to work.
Here is the code that I have (Red is the field I need the NULL values):
Private Function PurchaseFilter()
Dim strFilter As String
Dim bFilter As Boolean
bFilter = False
strFilter = ""
[Code] ....
View 14 Replies
View Related
Apr 13, 2014
I have a search form that has 8 criteria fields, of which the user can fill (from combo boxes and txt boxes) any number of them to narrow or widen the search.This by the way works perfectly. What I want to have is a message box pop up if the user does not enter any criteria and click search.
I tried stringing multiple if isnull statements together but realised that because I have an onload function that sets all fields to "" the isnull function won't work, so have changed this to the Len function.But when I run it, it just skips straight past the len line and opens the search detail form regardless. I suspect I have the order of things wrong, as it does not throw up any errors when run.
Code:
Private Sub Form_Load()
Me.PCNumberIn.Value = ""
Me.SerialNumberIn.Value = ""
Me.DeviceTypeIn.Value = ""
Me.DeviceModelIn.Value = ""
[code]...
View 5 Replies
View Related
Nov 26, 2007
I have a table that has several fields that contain a date if a user is licenced to use a certain piece of equipment and is null if not. Each recor has other data in it such as name, and a unique identifier (numeric). What I want to do is make a list of the fields which have a date in them to create a licence for what they can operate. Any help on which way to go...pretty new at access.
View 14 Replies
View Related