Modules & VBA :: Time Field Selection

Jun 11, 2013

I have a table with several fields including the following 3 fields:

dtmAppoint Date = stores appointment date
dtmAppointTime = stores appointment time
lngAppointDoctorID = stores doctor's id for specific appointment

When I enter a new appointment, I want to know whether a specific combination of these 3 fields already exists. The doctor is actually a dentist and maybe another appointment has already been placed for the same dentist on a different chair. Creating a recordset as indicated below works but I am having some problems with comparing Time (dtmAppointTime). The following works but I need to extract Hour, Minute and Second and put it into string variable strTimeDum.

Code:

rstSearch.Open "SELECT * FROM tblAppointment " _
& " WHERE (clng(dtmAppointDate) = " & CLng(rst!dtmAppointDate) & " )" _
& " AND (dtmAppointTime = #" & strTimeDum & "#)" _
& " AND (lngAppointDoctorID = " & lngAppointDoctorID & ");", CurrentProject.connection, adOpenKeyset, adLockPessimistic

Any way to retrieve the records that correspond to the specific time or a simpler way to access the records of interest?

View Replies


ADVERTISEMENT

Modules & VBA :: Combo Box Query Field Selection

Jul 31, 2014

I'm trying to write a query to allow the user to search through records.

To make the interface simple I just want a combobox to select the search field and a text box to enter the search string.

My problem is trying to build a query where the value of a combobox on a form is used as a field in the query.

View 3 Replies View Related

Modules & VBA :: Unbound Textbox To Display Memo Field Based On Listbox Record Selection

Apr 21, 2014

My table:

tblHeatTreatment
- HeatTreatmentID - PK
- HeatTreatmentDesc - Text
- HeatTreatmentDetails - Memo

My form has a listbox (lstHeatTreatments - Multi-Select disabled) that displays Heat Treatment descriptions and an unbound textbox (txtHTDetails) that I would like to have display the corresponding memo field when a description is selected from the listbox.

This is my code so far:

Code:
Private Sub lstHeatTreatments_AfterUpdate()
Dim myConnection As ADODB.Connection
Dim myRecordSet As New ADODB.Recordset
Dim mySQL As String
Dim selectedRequirementKey As Long
Set myConnection = CurrentProject.AccessConnection
Set myRecordSet.ActiveConnection = myConnection

[Code]....

When I run the code I get an error:

Quote:

Run-time error '-2147352567 (80020009)':

The Value you entered isn't valid for this field

When I debug, it highlights:

Code:

Me.txtHTDetails = myRecordSet.Fields

View 3 Replies View Related

Modules & VBA :: Default Property For Control Bounded To Date / Time Field

Dec 4, 2013

Access 2007

In a table I have 2 fields:

D1 , Date/Time , DefaultValue: Date()
D2 , Date/Time , DefaultValue: Date()+1

In a form (bounded to this table) I have, of course, 2 controls bounded to this fields:

txtD1 and txtD2

If the user change the value in txtD1 (using the Date picker) I like to change the DefaultValue for txtD1 to the new date and the DefaultValue for txtD2 to the new date + 1 day. Something like this:

Code:
Private Sub txtD1_AfterUpdate()
Me.txtD1.DefaultValue = Me.txtD1
Me.txtD2.DefaultValue = Me.txtD1 + 1 day
End Sub

I tried whatever crossed my mind... with the same "result" : #Name?

My Regional settings:

Short date format: dd.MM.yyyy
Date separator: Dot
Simple: 05.12.2013

View 14 Replies View Related

Adding Minutes To Time Based On Selection

Apr 28, 2005

My table, TblTYPE, will contain two field.
TYPE
DURATION

There will only be 7 records in this table:
FUS, 30 minutes
POS, 30 minutes
PRE, 30 minutes
NOV, 90 minutes
FUL, 90 minutes
ANN, 90 minutes
NPB, 60 minutes

1st question: How do I enter only minutes in the table for field 2?

------

I want the following to happen.
The end-user enters the start time and the type. As soon as the type is entered, field three calculates an end-time based on the start time and the type. When the type is entered, the minutes listed in field two of the type table are added to the start time (giving you an end time).

Can anyone help me?
1.) How to properly format the minutes in the original table.
2.) How to add the minutes to the original time in a query.

Thanks!
Scott

View 2 Replies View Related

Forms :: Selection On Price / Stock And Delivery Time In One Query

Dec 13, 2013

I have a table with following structure :

Fabcode Price Stock Date Supplier

Fabcode : the unique code of the article
Price : the price by this supplier
Stock : quantities for the moment in stock by this supplier
Date : When there is no stock at this supplier, the estimated time of arrival
Supplier : name of the supplier

A selection for looking the lowest price for a supplier who has stock is no problem. But I want also the fastest delivery date when no one has stock.

Example

Fabcode Price Stock Date Supplier
Product1 5 3 A
Product1 6 4 B
Product1 7 5 C
Product1 8 6 D
Product2 14 73 A
Product2 12 56 B
Product2 15 14 C
Product3 30 0 30/12/13 A
Product3 24 0 B
Product3 25 0 26/12/13 C
Product3 32 0 26/12/13 D

Result :
Product1 5 3 A (because supplier A has stock and the lowest price)
Product2 12 56 B (because supplier B has stock and the lowest price)
Product3 25 0 26/12/13 C (because no one has stock, but supplier C has the shortest delivery time AND the lowest price)

Remark 1 : when there is no delivery date (and no stock), this supplier should be ignored for that product
Remark 2 : when no one has stock, the delivery date is priority, when 2 supplies has the same delivery date than the price is priority.

Can this in one query or SQL-statement ?

View 6 Replies View Related

Forms :: Automate Combobox Selection Based On Current Time

May 26, 2015

I have a form with continuous sub form.

The main form contains a combobox, populated from a query which pulls in specific data (time) from a table

The subform is linked to the combo box on the main form. Based on the combobox selection, the subform updates with associated records with the combobox selection

I would like to add additional functionality in the form load event, that would read the current time and identify the nearest value in my combobox.

I have tested the code below behind a button and it works

If Time() > "13.00:00" And Time() < "14:30:00" Then
MsgBox "The Time is " & Time()
cboPricingCADeadline.Value = "14:30:00"
Else
cboPricingCADeadline.Value = "NA"
End If

Would a loop through the recordset of the Combobox be best used here? Set the first and second values of the recordset to variables, query the time and then return the value if statement is true, or move to the next record in the rs replacing the first and second variable values

eg
If value1 > time() and value 1 < value2 then
cboPricingCADeadline.Value = value1
end if

If this is a good lead, how do I go about setting up my recordset?

View 4 Replies View Related

Modules & VBA :: Calculating Elapsed Time Within Time Period

Dec 1, 2013

I have a working dB which can calculate a shift duration and sum total all shifts worked within a period for the purpose of producing a labor report for payroll. I have successfully used the DateDiff function and converted the minutes to HH:MM on my form and reports. Now I want to calculate elapsed time for a specific period within a shift, I'll call it OtherHours and I am aiming to calculate a portion of time that meet the following conditions below. I am using field names of [PunchIn] and [PunchOut] and both are of type General Date.

IF [PunchOut] ISNOT Saturday,Sunday
EXIT FUNCTION
ELSE
IF [PunchOut] ISNOT Between Midnight and 0559 hours
EXIT FUNCTION
ELSE
DATEDIFF ("n", <MIDNIGHT>, [PunchOut])

My thoughts are to solve the DateDiff portion and then figure out how to apply the conditions within the IF statements.

View 4 Replies View Related

Forms :: Add Time Value To Time Data Type SQL Server Field In Access

May 6, 2015

how to be able to enter time in access form the same way as if would be an access table (1p = 1:00 PM; 1.25 = 1:25 AM etc)

View 1 Replies View Related

Forms :: Update Time Portion Of Date / Time Field

Aug 29, 2013

I have a date/time text field on a form with the General Date format and a combo box next to it that has sequencial times as the row source (IE. 12:45 AM, 1:00 AM, 1:15 AM, 1:30 AM, ETC.) When the user chooses a time in the combo box, I want the time portion of the text box to be updated with the chosen time in the combo. I have tried a few things but cant seem to get it right.

View 4 Replies View Related

Tables :: Auto Populating A Field Based On Selection Of Other Field

Jun 27, 2014

I (will have) a form which a user fills in to enter new data.

I have two fields,

"Branch" and "Branch ID" (Branch ID will not be on the form, just in the table)

Branch will be fed by a combo box with seven choices. I would like it so that when "Branch" is populated it autopopulates Branch ID with a code which relates to the branch, so for example

BRANCH BRANCH ID
Braintree BRA
Colchester COL

View 4 Replies View Related

Forms :: Limit Form Field Selection Depending On Another Field

Feb 5, 2014

I am creating a training database and first I have tables in relationship to the courses:

tbl_Courses
Course ID (Primary Key)
Course Title
Objectives

Instructors (lookup field allowing multiple instructors to be selected, meaning they are skilled to teach the course)

tbl_Instructors
Instructor ID (Primary Key
Last Name
First Name
Full Name (Caluclated to put Last Name, First Name)

[code]....

What I am trying to do on a form to create a new event is once the user selects the Course from the Course ID combo box, then I need the Instructor combo box to only display the instructors who are skilled to teach the course which are selected in the tbl_Courses.

I can get all Instructor ID's, but not the names and the class that has multiple instructors show on one line.Should I have not put the Instructors field in the tbl_Courses? Do I need another table for instructor skills or something?

View 1 Replies View Related

Ignore Time In Date And Time Field

Mar 6, 2007

Hi,

Wonder if someone can help please. I'm quite new to Access so please bear with me.

I have a data field in my database consisting of both a date and time.

I then have a form containing two fields where the user can type a 'To' and 'From' date to extract the records that they are interested in. The query behind this uses the 'Between[Enter The Date] And [Enter The Date]' coding.

The problem is that because the field contains a time it doesn't return any records when I run the query.

Can anyone offer a bit of guidance on how I could ignore the time part of the field perhaps by adapting the above.

Many thanks

Chris

View 2 Replies View Related

Sort By Time Only In A Date / Time Field

Mar 19, 2014

I have a column/field named [DateTaken] which contains test dates and times in the same cell. I am needing to find those with a test time less than 2:30 pm or <14:30pm.

data looks like this:

8/22/13 4:23 PM
1/29/14 12:21 PM
1/28/14 3:27 PM
8/26/13 4:27 PM

[code]....

this is what I have come up with to extract the time component of data set so that I can then later, sort it by the time in a query.

JustTime: TimeValue([YourField])
JustTime: ("hh:mm",([DateTaken])) and or ("hh:mm",[DateTaken])

I get either invalid operator or invalid syntax errors trying both of these.

View 5 Replies View Related

Modules & VBA :: Last Selection List Box?

Apr 6, 2014

I have a form where I add a new event, and it gets added to a list box in another form, I was intending to select the most up-to-date record within the list box but it seems to keep selecting the old latest record and not the new record that ive added. I had tried to select the first record but then move to the last record hoping it would refresh but that still doesn't work.

This is the code I used below:-

Quote:

'Select last event record added to event list box
Me.lstPatientEvents = Me.lstPatientEvents.ItemData(Me.lstPatientEvents.L istCount - 1)
lstPatientEvents.Selected(lstPatientEvents.ListCou nt - 1) = True

View 1 Replies View Related

Modules & VBA :: Record Selection From List Box

Oct 18, 2013

I have a form that allows me to change the information for a list of personnel. On this form I have a list box that displays all the personnel in the list. There should never be more than 12-15 people in this list so it's an effective way of selecting records, however I can't figure out how to make the form select the record that is tied to that person from the list.

In VBA I've tried creating an "On Click" command for the list that, when a name is selected, is brings up the corresponding record. I thought I could use a DoCmd.FindRecord but I guess I don't quite know what I'm doing. I didn't want to use SQL to limit the records to just the one that matched I wanted to keep it simple if possible.

Code:
Private Sub Personnel_List_Click()
DoCmd.FindRecord Personnel_List, , True, , True
End Sub

The Personnel_List box is tied to the Personnel_Table, and the table only displays the names available.

View 3 Replies View Related

Modules & VBA :: Data Selection And Checkboxes

Sep 13, 2013

We have a small lab database where we insert the results of a water plant test. The results can be either Before treatment or After treatment.

And it can be treated numerous times a year.

I have created form with a drop-down box to select the customer and a button to show reports for the selected customer.

But I also want to add 2 check boxes: a Before treatment and After treatment box. And also add a date range.

So when selecting to view reports our users can select a date range example:

01/01/2013 to 01/10/2013 and a check box so users can select if the results to be displayed are Before or After treatment.

View 1 Replies View Related

Modules & VBA :: Event Procedure On Selection

Jun 27, 2014

I have a form with a field called duration.

The user selects AM,PM or All Day from a list

If the user chooses All Day I want to create a duplicate record

DoCmd.RunCommand acCmdSelectRecord
DoCmd.RunCommand acCmdCopy
DoCmd.RunCommand acCmdRecordsGoToNew
DoCmd.RunCommand acCmdSelectRecord
DoCmd.RunCommand acCmdPaste

However I would like the duration in the first record to be AM and the Second record to be PM

So something like Iif [Duration], "All Day" run procedure.

Else IIF do nothing.

View 2 Replies View Related

N Per Field Selection?

Dec 29, 2006

Hi

I have a db of about 10,000 records or so. This is a list that will be used for emailing purposes...and I want to limit the number of records per company that are emailed to.

I need to figure out a way to limit the number of records per company....any suggestions?

Thanks

View 1 Replies View Related

Modules & VBA :: Clearing A Combobox Selection Not Whole Recordset?

Jan 31, 2014

I would like to be able to clear a combobox selection with code but nothing I have tried is working.

Most recently I have tried this:

Code:
Me.cboCompanies.ListIndex = -1

To no avail. The selection still remains highlighted in the control after the code is executed. I want the control to be blank. Also the control goes from being a combo box to a text box until escape is pressed and it is cleared

I have also tried using a simple Undo and that is not working either.

View 8 Replies View Related

Modules & VBA :: ComboBox - Record Selection From List

Mar 25, 2015

I have 1 combo box contains 2 columns look-up directly from the properties(Not VBA)

Now i want to select record from the list

Example: i want to select PM-1234-1111 so i dont want to type starting letter PM to select but i want to type 234 or 123 or somewhere in the middle or end to filter that contained text in all the items is it possible?

Any Property settings or any VBA code?

View 1 Replies View Related

Modules & VBA :: List Box Respond To Combo Box Selection

Dec 11, 2014

I am using access 2010

I am trying to get my list box to filter based on the selection of a combo box.

My Combo box cboOrgRole is on my main form and is bound to OrgRoleID - on form - frmOrgEntry

The unbound list box lstRoleList is in a tabbed subform - frmPersonnel

This is my data pull for lstRoleList

Code:
SELECT tbl00PersonRole.PersonRole, tbl01Orgs.OrgRoleID
FROM tbl00PersonRole INNER JOIN tbl01Orgs ON tbl00PersonRole.OrgRoleID = tbl01Orgs.OrgRoleID
WHERE (((tbl01Orgs.OrgRoleID)=[Forms]![frmOrgEntry]![OrgRoleID]));

This is the code I have on cboOrgRole AfterUpdate

Private Sub cboOrgRole_AfterUpdate()
Me.frmPersonnel.lstRoleList.Requery
End Sub

I have also tried Recalc - both throw a Compile error: Method or data member not found

My goal is to be able to select the role of the organization, (General Contractor, Architect, Engineer, or Client) and have it list the available titles for the specific organization type.

My "00" tables are library tables

View 12 Replies View Related

No Field Selection Available In Wizards

Mar 23, 2007

I'm somewhat new to Access, so I'm using the wizards to get me started to make forms and reports.

When you first click on the "Create Form by Using Wizard" it asks you to select the fields you want to use from the selected Table or Query. Unfortunately no fields show in the "Available fields" box.

I know I have fields in each table or query. I even tried to make a dummy table using their field names incase mine contained invalid characters.

I've tried it in both the Form wizard and the Report wizard.

The fields of all the tables and queries used to show up when I first install Access.

What am I doing wrong? Should I try to reinstall the program?

Thank you for your help,

Pam

View 6 Replies View Related

Field Selection In SQL From Form.

Nov 29, 2007

Hi

I cant find this for the life of me... this is the second day trying to figure it out.
Anyway enough crying:D

Question:
Either using a SQL statement or query builder, how is it possible to make the field selection come from a form, ie a combo box, text box etc. or a variable?

Reason:
Im trying to make a dynamic searching form which will allow the searching from customers via a few of many columns which reside in 4 different tables also. Using a cascading combo box system to eventually narrow down the correct one. The above is my first hurdle and I think once I get past this brick wall I will be back on my way.

View 10 Replies View Related

Modules & VBA :: Email Based On Department Selection In Form

Nov 29, 2014

I am trying to generate an email that will send a copy of the last record entered from my table "Main" to a departement email, based on the department field entry on my form.

I know that I can send emails both thru outlook as well as direct. Would prefer to sent the direct (without opening outlook). Here is what I'm working with:Table with record informaiton called "Main"

Form called "Action Entry" which contains the information that I would like to send- part of which is a feild called "Assigned To" which is a list of departemnts linked to a secondary table called "departments"

Table called " departments" which contains the following Fields: ID, Departments, Email.What I would like to happen is when I hit the exit button on my form, an email goes out to the "Assigned Department" email address associated to the select departmet, that shows the information in the form (which i expect will be a report saved as PDF). I understand some of the VB code to create an email, but don't knwo how to tell it to select the correct email based on the Department selected on the form.

View 5 Replies View Related

Modules & VBA :: Only One Record Yes And Others Revert To No Based On User Selection

Jan 12, 2015

My table has a yes/no field and about 10 records. I have created a form for the user to select which of the records he wishes to use - the records are displayed in a continuous form with a check box for the yes/no field. The user is to select one record by checking the check box in the record.

I know this should be obvious, but I can't see it. How can I make it so the user can only select one of the records (when he clicks on one, that one is yes and the others revert to no?

View 4 Replies View Related







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