Multiple Ifs And Null Controls

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 Replies


ADVERTISEMENT

Have Controls Null When Form Opens

Dec 14, 2005

What is the best way to have all controls in a subform empty when form opens? The form and subform are bound.


The following:

Private Sub Form_Open(Cancel As Integer)
Me.textDate = Null
End Sub

Produced error - "cant assign a value to object"

thanks in advance

View 6 Replies View Related

If Statement With Multiple Controls

Jul 14, 2006

Hello,

I have a form with multiple controls (textboxes) named:
Father
Mother
Child1
Child2

On the form there are also two checkboxes (check1 and check2).

I am using the following statement for each control and placed in in the OnCurrent event of my form:
If Not IsNull (Me.Fater) Then
Me.Check1 = "YES" (or -1)
Me.Check2.Value = False
End IF

Is there a way I can write one If statement saying:
If all controls Father, Mather, Child1 and Child2 or at least one of them has data, then Check1 should be selected and check2 emply. If all controls do not have data then ckeck1 should be empty and check2 selected.

Thank you.

View 2 Replies View Related

Multiple Queries Need For Different Controls

Aug 11, 2014

I've constructed a trivia database that consists of trivia questions that are classified into different categories. The DB also keeps track of which questions were used at which establishment. I am designing a form that will generate multiple rounds of trivia based on user criteria.

As seen here the user can specify the number of rounds and questions per round. Maximum number of rounds is 8 - the tab visibility is changed AfterUpdate of the number of rounds field.I have queries set up that do what I need for a single round - they choose random questions based on category, subcategory, difficulty and if they haven't been used at that client's before.

how to deal with multiple rounds without it becoming a headache. My tab layout has controls txtCategory1, txtSubCategory1, txtDifficulty1, txtType1, txtCategory2, and so on. Currently the queries use the values in the controls for Round 1. I would have to make eight copies of these queries (one copy for each round) in order to generate each round based on specific criteria, which would make a ton of queries. The other option is to use SQL statements in VBA, but this method doesn't like the [Forms]![frmCreateTriviaNight]![cboCategory1] in the code - I have to concatenate the names of the variables in and the code would be a mess.

View 2 Replies View Related

Firing Event For Multiple Controls

Jan 10, 2006

i have 15 text boxes named Qty1, Qty, Qty3, etc...

and another 15 text boxes named Comment1, Comment2, Comment3, etc...

i'd like to write an AfterUpdate event code that will apply to all of the Qty controls..instead of write 15 individual AfterUpdate events..

is this possible at all?!

View 6 Replies View Related

Create New Record From Multiple Controls

Aug 8, 2007

Hello,

I have two controls on my form that I want to reference in an append query to create a new record. The first is a text box, the second is a combobox that is populated with all of the dates associated with the text box. The selection of a date updates a subform based off of a hidden column (chart ID, an autonumber field based on combinations of record numbers and visit dates) in the same combobox.
I would like the user to be able to enter a new date and create a new record that would contain the next autonumber in association with the new date and the record number from the text box control. I have tried using an append query with the following SQL, but I consistently get errors referring to "type mismatch." Any help would be greatly appreciated; thanks in advance.

Code:Private Sub cboDOVSearchChart_NotInList(NewData As String, Response AsInteger)Dim ans As Variantans = MsgBox("The date you entered was not found. Do you want to add a newdate?", _vbYesNo, "Add New Date?")If ans = vbNo ThenResponse = acDataErrContinueMe.cboDOVSearchChart = NullDoCmd.GoToControl "cboDOVSearchChart"GoTo exit_itEnd If' add dateIf ans = vbYes Then Dim strSQL As String strSQL = "INSERT INTO Patient_Visits ([Medical Record Number], " _ & "[Date of Visit]) " _ & "Values (" & Me.[txtChartMR] & ", " _ & "#" & CDate(NewData) & "#)" 'this line has the arrow on debug CurrentDb.Execute strSQL Me.cboDOVSearchChart.Requery Me.cboDOVSearchChart = NewData Call cboDOVSearchChart_AfterUpdateEnd Ifexit_it:End Sub

View 2 Replies View Related

Modules & VBA :: Set Event Handlers On Multiple Controls

Aug 7, 2013

I am trying to set event handlers on multiple controls in code. This works:

Code:
Me.Controls("txtPosition" & Right(CStr(iLoop + 100), 2)).OnClick = "=UpdateTaskList(" & CStr(iLoop) & ")"

This doesn't:

Code:
Me.Controls("txtPostIt" & Right(CStr(iLoop + 100), 2)).OnGotFocus = "=PostItGotFocusHandler2()"

The second gives an error: "The expression you entered has a function that <databasename> can't find.

I suspect it may be a parameter mismatch, but the normal GotFocus event handler does not take any parameters.

View 2 Replies View Related

Modules & VBA :: Class Event For Multiple Controls On Userform

Mar 5, 2014

Basically I have a class event that works for all controls on any userform.

Its all working fine but I can't add an event to trap the click or mouse move of the userform itself.

Basically so when the cursor moves away from a control the label clears.

User Form Code

Code:
Option Compare Database
Option Explicit
'Define a collection and initialise the commandbutton event class
Private col As New Collection
Private newCmd As New clsEvents

[Code] .....

And here is the class Module

Code:
Option Compare Database
Option Explicit
'catch the event of Commandbuttons
Private WithEvents C0 As SubForm
'Private WithEvents C1 As CheckBox

[Code] ....

View 11 Replies View Related

Forms :: Using Multiple Calendar Controls With Same Control Source?

Feb 26, 2014

On the form I need to give the user the option to select a 'from date' and 'to date' and for this I have put in 2 calender controls which have the same control source(same table column). The problem I am facing is when I select a date from one calendar, the other calendar control automatically populates with the same date and vice versa.

I need to have a functionality where 2 different date can be selected and then when the Search button is clicked, then data within the date ranges should be displayed.

what changes I need to make to acomplish this ? find a screenshot of the form attached.

View 5 Replies View Related

Form Based Parameter Query With Multiple Controls Used For One Criteria

Nov 14, 2012

My form-based search mechanism uses controls to set the parameters for the query data source.

I have one field call quantity in stock. I could you a Between and And method to allow the end user to input the stock quantity they want.

HOWEVER, i would love it for the user to first select the Comparison Operator (e.g. > , <, >=, <=) from a combo box and then in an adjacent text box, enter the quantity.

The expression i entered in the query goes something like this.... Forms![frmSearch]![cboRange] & [Forms]![frmSearch]![txtQuantity]

When i try and run this, i get the message "THe expression is too complex to be evaluated".

View 5 Replies View Related

Is Not Null / Multiple Fields

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

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 2 Replies View Related

Modules & VBA :: Multiple Combo Box IF THEN To Filter On NULL

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

Forms :: Trying To Detect Multiple Null Or Zero Values

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

How To Handle Multiple Null Values Using Form-based Parameter Queries

Nov 19, 2012

i'm creating a search form giving the end user a range of controls to use when filtering/searching data. See the image.But, i think my range search (using the textbox) to put in a lower and upper limit...is preventing this from working. In fact, when i put data into all the controls, no data pops up in my subform.

My query data source can also be seen...showing you how i've handled teh null entries. (i need to put in a null 'handler' for the two textboxes?)

View 2 Replies View Related

Modules & VBA :: Switch Function - A Null Makes Whole Column Null

Nov 16, 2014

I do not understand what is happening here. I have foll0wing line in a calculated query field:

m: Switch([EmpID]<5,1) ' run Query 18 in attached example, A2007/2010

this produces 1 for all EmpID<5 and Null for all other EmpID's. All as expected.

But if I do this:

m: Switch([EmpID]<5,1,[EmpID]>=5,Null) ' run Query 19 in attached example

then the entire column is set to Null

View 2 Replies View Related

Modules & VBA :: Invalid Use Of Null With No (obvious) Null Values

Jul 5, 2013

It might be an easy one but I just wasted the past hour deciphering through my code in order to solve the run-time error '94' that I'm getting when trying to execute the following code:

Code:
Private Sub cmdUpdateDates_Click()
'###################################
'This sub aims at combining the timesheet date and the start and end time into the fields [Start Time] and [End Time].
'###################################
Dim intCounter As Integer
intCounter = 0
Dim rs As ADODB.Recordset

[Code] ....

View 1 Replies View Related

Query With Is Null Returning Not Null Records

Apr 18, 2006

Hello all,

A bit of a weird one, I've got a query and the criteria for showing records is that one particular field is null. However the query is showing records with the values in the field chosen for the Is Null.

Not sure why this is happening, has anyone come across this problem before?

Thanks.

View 4 Replies View Related

Combo Criteria If Not Null Or Is Null

Apr 3, 2008

I am having problems with setting up a set of combo boxes.

What I am trying to do is if combo Productline is empty then in combo PartNumber would show all products but if combo Productline has a value selected then in the combo partnumber would only be able to select the partnumbers in that productline.

View 4 Replies View Related

Invalid Use Of Null ? How To Assign Null

Nov 16, 2006

Hi, I have some problem with assigmnet with date and string variable. what i wana do is get data from Forms textboxes into variable and then by insert query send to history table.

the problem occurs when there is blank textbox its says invalid use of null.

e.g
myStringVariable = Forms!myform!EmpName
myDateVariable = Forms!myform!EmpDOB

this code is behind the update button which i press when ever i want to shift data to History table

so when the fields are empty the invalid use of null error arrise

any idea how to handle this null specially in date

View 4 Replies View Related

Field Criteria: Is Null; There Are Null Values In That Field; No Records Are Returned

Nov 16, 2007

I think the title pretty much sums it up....

I have a query where data is first sorted by user input; first field's criteria: [fieldname], then by another field's criteria: Is Null.

I know there are records containing null values in the second field, as I have run a select query with the criteria: Like "*", to make sure they are null, and not zero-length-strings.

The query is refusing to return any results...

Any ideas?

View 10 Replies View Related

Controls.Add

Apr 21, 2005

I need create controls with Controls.Add in one forms on event LOAD.

View 2 Replies View Related

Too Many Controls??

May 11, 2005

I have a form in my Access database that after trying to add another field to it today, I get the error "Microsoft Access can't create any more controls on this form or report."

I'm guessing I reached some type of limit that I was not aware of. How can I get around this?

View 10 Replies View Related

More Than One Row Of Tab Controls?

Jul 19, 2005

I read somewhere that you can have more than one row of tab comtrols on a form. I have searched the forum for any threads or posts on the issue but can't find anything. Does anyone know how to do it?

View 2 Replies View Related

Two Tab Controls

Aug 17, 2005

is it actually possible to place a tab control within another tab control? every time i try to put one on it ends up beneath? would be good to have because even with one tab control my forms still look very busy!!

View 1 Replies View Related

Tab Controls

Jan 27, 2005

Is it possible to put a tab control on a page of a tab control?

And if so, how?

Everytime I try to fix another tab control on an already existing tab control, it places it on the form, not the control.

View 1 Replies View Related







Copyrights 2005-15 www.BigResource.com, All rights reserved