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.
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"
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.
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
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
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.
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".
I have a field which shows numbers 1-8 or is null. I want to group this to show if its 1,3,5,7 then it shows as "BOOK" else if its 2,4,6,8 then its "CHAIR" and if its null then show it as null Can anyone help - I am using Access 2003
I'm new to programing so if this is not possible please tell me! Because this is going to be hard to explain I attached an example.
I have a Main form that a user will open, this is the only window that will ever pop up in front of them so it has a subform that will open differnt froms by picking buttons on the left.
One of the sub forms is the Member Information form, this form will show member information than at the bottom has another subform that will allow a user to pick a button above it to open another subform (this is so member info is always show and a member can be registered, pay...all different subforms)
on the Event Register subform the "Class" pulldown is based on the event that was pick just above it.
Issue: when I am in the main form, I can not get the class pulldown to work it always prompts me for "enter Parameter Value". I have tried the following SQL statements in the row source and noting work.. what am I missing???
SELECT SubCatList.SubCatName, SubCatList.EventName FROM SubCatList WHERE (((SubCatList.EventName)=[Forms].[MainFRM]![MemberInfoFRM].Form]![EventRegFRM].[Form]![EventName]));
and
SELECT SubCatList.SubCatName, SubCatList.EventName FROM SubCatList WHERE (((SubCatList.EventName)=[Forms]![MainFRM]![MainSubFRM]![Form]![memberinfoFRM]![MemberSubFRM].[Form].[EventName]));
I thought the whole point of the ; sign at the end of a sql statement in access was so that you can run more than one query at a time? if this is the case, could you tell me why this doesn't work? Code: sqlStr = "UPDATE tabControlFeeType SET FeeAmount = " & txtFirst.Text & " WHERE KeyFeeType = 1;" & _ "UPDATE tabControlFeeType SET FeeAmount = " & txtSecond.Text & " WHERE KeyFeeType = 2;" & _ "UPDATE tabControlFeeType SET FeeAmount = " & txtThird.Text & " WHERE KeyFeeType = 3;" Dim comm As New OleDbCommand(sqlStr, conn) comm.ExecuteNonQuery() the query doesn't work if I put it straight into access either?
I have the following code on an After Update event:
If Me.Program_Type.Value = "(1) 45 Minute Formal" And Me.Cost_Category = "Full Price" Then Me.ProgPriceTxt.Value = "85" End If
This works fine. When I add another "And" to the statement, however, it no longer functions:If
Me.Program_Type.Value = "(1) 45 Minute Formal" And Me.Cost_Category = "Full Price" And Me.PavRentCheck = False Then Me.ProgPriceTxt.Value = "85" End If
Is it possible to put three conditions into an And statement? This thread seems to imply so (it's a different situation, but it seems close enough).
I believe it doesn't have anything to do with my text boxes or fields because this same issue has occurred in other places when I tried to have three conditions in an And statement.
I've "inherited" someone else access DB and I need to interpret this selection logic:
IIf(IsNull(a.[Lifecycle Stage 4 Sub-Stage]),IIf(IsNull(a.[Lifecycle Sub Stage 2]), a.[Lifecycle Stage], a.[Lifecycle Sub Stage 2]), a.[Lifecycle Stage 4 Sub-Stage]) AS [Sanitized Phase],
What I think it's saying:
If [Lifecycle Sub Stage 2] is null, use [Lifecycle stage], if [Lifecycle Sub Stage 2] is not null use [Lifecycle Sub Stage 2]. If [Lifecycle Stage 4 Sub-Stage] is not null, use [Lifecycle Stage 4 Sub-Stage].
I am not 100% sure if this is the correct interpretation as I have not had much previous experience interpreting multiple IIF statements in access. My aim is to migrate this process to Oracle, so I am just trying to get a handle around all the Access logic so that I can replicate the same behavior in another environment.
First off thanks for this forum it has gotten me this far. 2nd I have a question on how the best way to accomplish this. So I have a table that has customer info in it, Account #, Name, city, state, Zip. I have a form that allows users to type in fields to query for particular info. My select statement is below.
Private Sub cmdSearch_Click() Dim strSQL As String, strOrder As String, strWhere As String Dim dbNm As Database Dim qryDef As QueryDef Set dbNm = CurrentDb()
If Not IsNull(Me.txtCSONME) Then strWhere = strWhere & " (tblCONSOLIDATED.COMPANY_NAME) Like '*" & Me.txtCSONME & "*' AND" End If
If Not IsNull(Me.txtCSOSLD) Then strWhere = strWhere & " (tblCONSOLIDATED.ACCOUNT1) Like '*" & Me.txtCSOSLD & "*' AND" End If
If Not IsNull(Me.txtCSOSSM) Then strWhere = strWhere & " (tblCONSOLIDATED.REP_NUMBER) Like '*" & Me.txtCSOSSM & "*' AND" End If
If Not IsNull(Me.txtCSOARN) Then strWhere = strWhere & " (tblCONSOLIDATED.CONTACT_NAME) Like '*" & Me.txtCSOARN & "*' AND" End If
If Not IsNull(Me.txtCSOCTY) Then strWhere = strWhere & " (tblCONSOLIDATED.CITY) Like '*" & Me.txtCSOCTY & "*' AND" End If
If Not IsNull(Me.txtCSOST) Then strWhere = strWhere & " (tblCONSOLIDATED.STATE) Like '*" & Me.txtCSOST & "*' And" End If
Everything works but I can only search for one state. So now I want to search for two or more states. I've added multiple text fields on my form and have tried approaching it that way. Unfortunily if I add txtCSOST2 for example then add
If Not IsNull(Me.txtCSOST2) Then strWhere = strWhere & " (tblCONSOLIDATED.STATE) Like '*" & Me.txtCSOST2 & "*' And" End If
tblCONSOLIDATED.STATE has to contain both state codes. If I put an Or instead of And I get both states and all other search critera is ignored. Basically I need to be able to query by two or more states and it still be an and I guess. For example we may have a Rep A (Me.txtCSOSSM) that goes into TX & OK but Rep B also has a peice of TX. If I'm looking all the accounts that are in TX & OK and are Rep A and I use the below code I get all of the TX & OK accounts as well as Rep A accounts.
If Not IsNull(Me.txtCSOST) Then strWhere = strWhere & " (tblCONSOLIDATED.STATE) Like '*" & Me.txtCSOST & "*' Or" End If
If Not IsNull(Me.txtCSOST2) Then strWhere = strWhere & " (tblCONSOLIDATED.STATE) Like '*" & Me.txtCSOST2 & "*' Or" End If
I know that has to be simple I just wrap my brain around it. Let me know if this needs further explaination.
I have tried searching and haven't found an answer to this question.
I have a calculated field in a query that returns a aging date to an invoice. I want to take that aging date and apply it to a multiple If statement. I tried a joining field, but it's not working. A simple multiple If statement should do the trick though.
If AR is: 0-10 Then return: "Current AR"
If AR is: 11-40 Then return: "001-030"
If AR is: 41-70 Then return: "061-090"
There are more, but I can figure that part out once these are solved. Any help would be appreciated.
I'm trying to create a report that does the following:
If the term "Other" is selected in the Time1 field, then the Time1 field will not be visible, but the field Other1 field will be visible and if the term "Other" is not selected in Time1 field, then the Time1 field will be visible and the Other1 field will not be. This is what I have for VBA code, but it is not working.
If Not IsNull(Me.Time1) Then If Me.Time1 = "Other" Then Me.Time1.Visible = False Else Me.Time1.Visible = True
I am creating a report that has a filter based on 3 separate listboxes. The user has the option of choosing one or more filter criteria from each listbox. The trouble I am having is if the user only chooses one filter, I need to adjust my filter string. This is the code that generates the filter:
I need to get this syntax right. I have something similar that worked before to open a report but now I am using the same code structure on opening a form and I can't get it.
[prikey] is an autonumber and that has given me trouble before with the syntax. [EstimateFlagCleared] and [WarrantyFlagCleared] are Yes/No fields.
Dim maxFlag As String Dim flagCriteriaWarranty As String Dim flagCriteriaEstimate As String
Look at the below SQL 'INSERT INTO' statement ? I'm trying to insert multiple variable values into an 'INSERT INTO' statement. I'm getting the below error message. The code is listed below. I started out with two (2) variables, but will have thirteen to insert into a table. Also, in the code below is the VBA statement to retrieve the variable data. I'm getting the data, but cannot insert the data into the table.
Private Sub Test2_Click() Dim strSQL As String Dim strSalesman As String Dim strContentArea As String DoCmd.SetWarnings False
[Code] ....
Error Microsoft Visual Basic popup Run-time error '3061'
I have a problem that I can't seem to solve in SQL for my access 2010 query.
Let's say I have a the price of and for every year.
In the tables I have A building number, a building type, and electricity and water predictions for this year and many upcoming years (up to 40 years)
I need to apply a change to any building with the building type BRT to show only 10 percent of the electricity and water for ALL years (up to year 2052). So building 5 would show 8.5, 5.4, 9.5, 7.4, and so on.
Following is the one liner Update statement which, works perfectly
strsql = "UPDATE tblCurr SET tblCurr.Currencyname = [forms]![updatecurrency]![txtcurname] WHERE (((tblCurr.Currencycode)=[forms]![updatecurrency]![txtcurcode]));
I am trying to get a Case Statement to evaluate multiple conditions. Example: below when I get diagnosis code 20400 and the age_at_diagnosis is 40 the code is basically ignoring the second condition of the Case "And rs![Age_At_Diag] < 18". How do I get the code to recognize both conditions?
Code:
Private Sub cmd_Update_Conditional_Codes_Click() Dim rs As DAO.Recordset Dim rs2 As DAO.Recordset
I'm trying to construct an SQL crosstab query that will output data like the picture I've attached in the .zip file.
The four variables from the data table would be [Client Accounting].[Marketer] (the left vertical column), [Client Accounting].[Closing Date] (the higher level horizontal column grouped by month), [Client Accounting].[Write Off] and [Client Accounting].[Refund] (the lower level horizontal columns as sums)
The totals column at the bottom and the two vertical columns at the right would be made in the report and wouldn't need to be in the query.
This is what I have so far but I don't know how to add a second TRANSFORM statement to be included and grouped by month!
Code: TRANSFORM Sum([Client Accounting].[Refund]) AS SumOfRefund SELECT [Client Accounting].[Marketer] FROM [Client Accounting] GROUP BY [Client Accounting].[Marketer] PIVOT Format([Closing Date],"mmm") In ("Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec");
Now, I know that something in the UPDATE statement does not match my select statement.What should my Update Statement be, in order to update all the columns in the joined tables?