I have a form to enter attendance in that pulls students from a StudentEnrollmentTable based on FacultyName which is selected from a combobox that runs the following code:
Private Sub cboInstructorName_Click() Me.Requery End Sub
A query (StudentAttendanceBYFaculty) is run each time a faculty name is selected. On the form their is a field name TempClassesAttended which is bound to a field of the same name in the StudentEnrollmentTable. Teachers will enter attendance data and run an append query to append the current form records to the StudentAttendanceTable. Each time the form is repopulated the most recent TempClassesAttended values are pulled into the form. This is what is expected.
Now I want to load Null values into the TempAttendance field on the form each time the Faculty selects their name and runs the event. I looked at code online and it seems easy enough, but I don't know enough to make it work. This is the code suggested:
UPDATE TableName SET FieldName = Null OR UPDATE MyTable SET MyField = Null
how to include this into the current event so that the event will return the faculty records with Null values in the TempAttendence field.
Access 2010..One organization that we work with provides us with a block of numbers for each of the two types of contract products we order from them; we do order non-contract stuff from them also.The block of numbers are the same (i.e. 20000 to 30000 this year) for each of the two products. This means that each product can have the number 20000, for example. We call this the Tracking Number. If it is one of these products, we need to select the Contract Number.
For all other one off orders we have with them, we assign our own Tracking Number starting with 00001. This Tracking Number cannot duplicate unless it is one of the aforementioned two products.Both the Tracking Number and Contract Number are in the same table. The user selects the Contract Number from a form (connected to the Contract Number table that has all the details on the contract) and the Contract Number is populated in the same table that has the Tracking Number.Each order must have a Tracking Number (no null)..Not all orders need a Contract Number (null okay).The Tracking Number and Contract Number combination cannot duplicate.I tried setting the primary keys to more than one field in the table, but they cannot have null values.
If not... I have been working on Plan B.... an AfterUpdate on the form (either the form or a field... don't know yet) that looks at a query that only has results if there are duplicate values.
frmUsedOilContract (contains a header and a subform) subfrmUsedOilContract (contains a few controls) [datasheet view]
- Removed Date - Voucher Number - Building Number
I implemented some code so that a temporary default value could be set for the date and the Voucher Number. I also have the default value for 'txtRemovalDate' set at 'Date()'.
PHP Code:
Private Sub txtVoucherNumber_AfterUpdate() 'Set current value to default value. txtVoucherNumber.DefaultValue = txtVoucherNumber.ValueEnd Sub
PHP Code:
Private Sub txtRemovalDate_AfterUpdate() 'Set current value to default value. txtRemovalDate.DefaultValue = txtRemovalDate.ValueEnd Sub
Also have code so the default value is null when the form is opened.
PHP Code:
Private Sub Form_Open(Cancel As Integer) 'Set Default Value properties to nothing. txtVoucherNumber.DefaultValue = vbNullString txtRemovalDate.DefaultValue = vbNullStringEnd Sub
This all works great until I try to change the date. If I use the default date (today's date), the new record will stay with today's date. If I change it to a different date, the new record displays a time instead.
good morning all, I am using the afterupdate event on this forms field. If this date field is NOT EMPTY, then i want the next field to be visible. Here is the code i have
If Me.quotedate = ????????? Then Me.quotehow.Visible = True Else Me.quotehow.Visible = False End If
I have done this with text fields where i have a defined data to be = to, but for a date field what do i put in ?????????? to show is not null?
So I went searching through the forums and found a thread that provided coding for getting the # of years and months from two dates:
Function fAgeYM(StartDate As Date, EndDate As Date) As String 'Purpose: Returns the difference between StartDate and Date in full years and months 'To call: ' ? fAgeYM(#1/21/04#, #1/19/06#) 'Returns: ' 1 years 11 months
fAgeYM = Int(intHold / 12) & " years " & intHold Mod 12 & " months "
End Function ------------------------------------------
That's perfect for what I'm wanting but I'm doing it with Hire/Term dates. So I want to be able to see how long past and present employees have worked in the company. Obviously that makes the Term field Null at times. With the coding above it requires a date to be in the EndDate field. How can I change it to allow for a null field in which the field would essentially be the current day's date? [Now()]
If (DataErr = 2113) Then Select Case Screen.ActiveControl.Name Case "DA_Start" MsgBox "invalid date", vbExclamation Me.DA_Start. = Null End Select Response = acDataErrContinue End If End Sub
This will pop up the error message, but will trigger the debuger when gettin to "Me.DA_Start = Null"
I have a Product form that shows the details of each of the Products in my Product table. I also have a "Pick a product" combobox (who's rowsource is being fed by the same Products Query that feeds the form). This allows you to go straight to a particular product by selecting its name. So far, so simple.
I've since added a couple of combobox filters which use different columns ("Product Type" and "Collection") to allow the user to get down to a more manageable recordset to then work with.
Of course, because the "Pick a Product" combobox is being fed by the Products Query, the combobox can end up showing products that are not contained in a filtered recordset. This is... sub-optimal.
Is there a way of telling the "Pick a Product" combobox to use the products listed in the recordset as its rowsource rather than the product query? So that it only lists the products the user has filtered down to?
I'm really lost on this one... How do I find the # of days it takes to complete a task between two date fields. For example: [DateRec] field is the field the app was first input to the database. [DateNumb] field is the date the first task was completed. So I understand, =DateDiff("dd", [DateRec], [DateNumb])) But I'm getting an #Error because often these two dates are the same date/equal, Or/ the DateNumb field may pre-date the DateRec date. Or/ one or both fields might be Null (blank). How do I set the formula on this?
Bottomline,I need to find the average # of days it takes to complete a task between two date fields for all tracking records. How do I do That???? HELP!
I am new to Access. I am after a vba script to run an update query.
I have a table named MYOB_Invent. I have a Query Named MYOB_Update.
The query is showing records where my field named Test1 is null.
I want to update records with null in the field to today's date (the date of the day that it is run) formatted as 18/08/2014 and the field next to it is named Updated (which is yes/no) from un-ticked to ticked for the updated values.
I would like a vba script to automate the process as I want to automate it via a commandbutton for users.
I'm using VBA & ADODB to maneuver through a recordset that contains a single record.
All variables are defined per Option explicit, and are all properly initiated.
When I run the SQL statement in SQL view of an Access Query, I get a single record with 7 fields. Each field contains the correct (non-null) value.
When I run the below code, I get message boxes that contain "*field name* = " -- the value is null. Code: Dim rs as ADODB.Recordset Set rs = New ADODB.Recordset rs.Open sqlstr, conn, adOpenDynamic, adLockReadOnly If Not rs.EOF Then rs.MoveFirst For i = 0 To 6 MsgBox rs.Fields(i).Name & " = " & rs.Fields(i).Value Next i rs.close End IfOh, and the kicker is: this code worked yesterday.
So what gives? My connection must be OK, otherwise the query would be bombing at the .Open command. I'm obviously receiving results, because it's delivering message boxes. But where did my values fall out? Like I said, I'm receiving results when I run the SQL outside VBA...
<edit>
Just in case you're interested, here's my SQL. My table contains a Float for turnaroundTime, and the Level is restricted to Lvl1 ... Lvl7. Code:SELECT [Lvl1Qry].[TheAvg] AS Lvl1Avg, [Lvl2Qry].[TheAvg] AS Lvl2Avg, [Lvl3Qry].[TheAvg] AS Lvl3Avg, [Lvl4Qry].[TheAvg] AS Lvl4Avg, [Lvl5Qry].[TheAvg] AS Lvl5Avg, [Lvl6Qry].[TheAvg] AS Lvl6Avg, [Lvl7Qry].[TheAvg] AS Lvl7AvgFROM (SELECT AVG([myTable].[turnaroundTime]) AS TheAvg FROM [myTable] WHERE [myTable].[Level] Like "Lvl1*") AS Lvl1Qry, (SELECT AVG([myTable].[turnaroundTime]) AS TheAvg FROM [myTable] WHERE [myTable].[Level] Like "Lvl2*") AS Lvl2Qry, (SELECT AVG([myTable].[turnaroundTime]) AS TheAvg FROM [myTable] WHERE [myTable].[Level] Like "Lvl3*") AS Lvl3Qry, (SELECT AVG([myTable].[turnaroundTime]) AS TheAvg FROM [myTable] WHERE [myTable].[Level] Like "Lvl4*") AS Lvl4Qry, (SELECT AVG([myTable].[turnaroundTime]) AS TheAvg FROM [myTable] WHERE [myTable].[Level] Like "Lvl5*") AS Lvl5Qry, (SELECT AVG([myTable].[turnaroundTime]) AS TheAvg FROM [myTable] WHERE [myTable].[Level] Like "Lvl6*") AS Lvl6Qry, (SELECT AVG([myTable].[turnaroundTime]) AS TheAvg FROM [myTable] WHERE [myTable].[Level] Like "Lvl7*") AS Lvl7Qry; </edit>
I am new to access. I have created a report form a query and have fields with a value of "0" or "$0.00" I would like to set a static textbox to Null. I belive it can be done with the IFF function but I get a syntax error.
I'm new to programming with Access but am attempting to create a new field in a table with an new date based on existing fields in the table.
The current fields are [Frequency], integer, [Risk], text, [Last Audit Date], date/time, and the new field is [Next Audit Date]. [Frequency] is a calculated field based only on [Risk] and is equal to "5" if [Risk] is "Low" and is "3" is [Risk] is "Medium" or "High", and [Frequency] is blank if [Risk] is (thus far it has never been empty).
What I need the new calculated field to do is return "N/A" (or blank, or anything easily separated really) if [Frequency] is blank, or if [Risk] is "Low" or "Medium". If [Risk] is "High", [Next Audit Date] should be equal to [Last Audit Date] plus 3 years. When I try to save the code, I get this message: "The expression could not be saved because its result type, such as binary or NULL, is not supported by the server."
This is my code now: IIf(IsNull([Frequency]),"",IIf([Risk]="Low","N/A",IIf([Risk]="Medium","N/A",IIf([Last Audit Date]="N/A","N/A",[Last Audit Date]+Year(3)))))
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.
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?
I have a form with Date of Death (DOD) field. I would like update DOD from a table dbo_patient into Z_Patients table.
I have set the datatype as Date/Time in the form for Date of Death.
Code: Private Sub Update_DOD() Dim rcMain As New ADODB.Recordset, rcLocalDOD As New ADODB.Recordset Dim DOD As String rcMain.Open "select distinct PatientKey from Z_Patients", CurrentProject.Connection
[Code] ....
However I am getting some error Run-time error '-2147217913 Date type mismatch in criteria expression in section below.
Code: CurrentProject.Connection.Execute "update Z_MAIN_Processed_Patients set DateOfDeath = '" & rcLocalDOD!date_of_death & "' where PatientKey = " & !PatientKey
I have a query where I display the [OPEN DATE] and [CLOSE DATE] of my cases. However, when I run this query sometimes the cases are not closed yet, therefore there are null values. However, I also have a field to calculate the datediff between these two dates. I need the [CLOSE DATE] field to display today's date when it is a null value so that I can still get a count of the days using datediff when I run the query.
I have a query that is set as a recordset. The query returns many values and one of the value is the Date field. How can I get the Last date value (as in the recent date entered in the sales table) and save it in a recordset.
Here is my code:
strSQL = "SELECT tblSales.* FROM tblSales;" Set rsQry = db.OpenRecordset(strSQL)
I need to get the last date field in a recordset, can this be done?
I have several forms that our machine operators have to enter data into several times during their shifts. The question/suggestion was brought up as far as having the date automatically fill in based on the time they enter on their screens. However, the tricky part is we use date based on shift. Our shifts are from 6:45am-6:45am the next day, so if they enter a time between those times, the date would be today, otherwise, the date would be tomorrow. Any suggestions?????
I have several forms that our machine operators have to enter data into several times during their shifts. The question/suggestion was brought up as far as having the date automatically fill in based on the time they enter on their screens. However, the tricky part is we use date based on shift. Our shifts are from 6:45am-6:45am the next day, so if they enter a time between those times, the date would be today, otherwise, the date would be tomorrow. Any suggestions?????
i'm a bit a database novice, and have a fairly simple database in Access2000 that records complaints of different categories with amongst other things 'reported' and 'resolved' date fields.
I have 6 queries/ reports that need to be run periodically, using a 'ReportStartDate' and a 'ReportEndDate'. When i run the reports they all use the same dates.
At present I have these set as parameters in each of the 6 queries, but it is a pain having to type both dates in 6 times, and there is obviously a good chance of me making a mistake in typing the dates 6 times.
What I would like to do is just set the ReportStartDate and ReportEndDate just once, so that it could be used by all queries/ reports.
I was thinking that the best way of doing this would be to enter the 2 dates in a table, but I can't see how this would then be linked to the main data table in the queries. I'm sure there must be a way around it...and i'm probably going about it the wrong way...any pointers would be greatly appreciated before it drives me insane!
I have a numeric field (long integer) in a table. I've set the format to fixed. No matter what I set the decimal places to, auto, 0 or 2, when I enter a value of 0.71, it displays as 1.00
In my form, I've also set the field property to fixed, but it displays the value as 1.