Problem With Simple Date Code!?!?

Jul 5, 2006

I got this to work easily on another form but on this particular form it doesnt work. I enter a command button and name it d1, then I enter this code for it to populate the current date in the field next to the box:

Private Sub d1_Click()
Date_Entered.Value = Date
End Sub

Can anyone see why it doesnt work :eek:

ERROR IS:
Run-time error '2465':

Database cant find the field 'Date' referred to in your expression.

When I enter a date field it enders whats in that field (blank) into the field I told it (Date_Entered) on my form.

View Replies


ADVERTISEMENT

Please Review This Code, (simple Code) New With Codes

Feb 16, 2006

Works great, but when I hit the number "3", (3 times in row) it will let me into the form. I want it to not let me in IF I don't know the password.

Where did I go wrong?

Private Sub Form_Load()
Dim pw As Variant

If InputBox("What is the password?", "Password") = "1" Then
Else
MsgBox "Invalid Password", vbCritical, "Sorry Charlie"
DoCmd.Close
If InputBox("What is the password?", "Password") = "2" Then
Else
MsgBox "Invalid Password", vbCritical, "Sorry Charlie"
DoCmd.Close
End If
End If


End Sub

View 14 Replies View Related

Help With Simple If Code

Jun 7, 2006

I am checking to see if a memo field and/or a text field has more than 1000 characters and if so then it calls a function that prints legal size paper vs. 8 X 11. It works fine except when the either field is empty. I have searched and searched the Forum and found many that are close but no cigar!

I know this involves a "IsNull" routine and I know I need to check both fields but can't quite come up with the right syntax. Right now if either field is empty I get an error msg = "Invalid use of Null"

Could someone please help?! Thanks in advance once again!
This is the basic code after setting the focus,etc....

If Len(strMsg) > 1000 Then
cmdOpenLegPrnt_Click

Exit Sub
End If

View 13 Replies View Related

Simple Code?

Apr 19, 2007

So far I have a query that picks up any collisions between booking dates with the following:

SELECT [Customer Details].[CustomerID], [Booking].[RoomNumber], [Booking].[DateFrom], [Booking].[DateTo]
FROM [Room Details] INNER JOIN ([Customer Details] INNER JOIN Booking ON [Customer Details].[CustomerID]=[Booking].[CustomerID]) ON [Room Details].[RoomNo]=[Booking].[RoomNumber]
WHERE DateFrom Or DateTo Between [Forms]![Bookings]![DateFrom] And [Forms]![Bookings]![DateTo] And ([BookingID]<>[Forms]![Bookings]![text38]) And (RoomNumber=[Forms]![Bookings]!RoomNumber)
ORDER BY [DateFrom] And [DateTo];


But the problem is that it doesn't pick up dates inbetween DateTo and DateFrom. So:

Booking 1
12/12/06
20/12/06

Booking 2
13/12/06
19/12/06

On trying to book Booking 2 it will not notify me of 'no clashes' when there are. As it isn't passing by the 12th or 20th my SQL doesn't pick it up.

Can anybody help me? I'm new to code so I'm probably missing the obvious but all help will be greatly appreciated.

Cheers
Luke

View 2 Replies View Related

Help With Simple SQL Code Required Please

Apr 30, 2005

Hi,

I have a database with 8 tables. One of these being staff

I have staffID as a Primary key in the table staff
The format of this is "STA"0000
and input mask "STA"9999

I would like staffID to be automatically generated by taking the value of the previous staffID (eg STA0001) and creating a new staffID for the next member of staff that is to be added (eg, STA0002).

I have access experience but have never had to use SQL code and am struggling. If anyone could be kind enough to help me with this I would be very grateful.

Thank You

Nicholas

View 7 Replies View Related

Simple Code Question

Oct 11, 2004

Just arrived here, so I hope this question is in the correct forum.
Here is my question

I have one field called ContractType, another field called Contract Description.
What I like to do is if ContractType = CO and Contract Description, DO NOT HAVE TEXT IN THE Contract Description field, flash the Contract Description field. How do I identify if there is text fill out in the Const_Description field?

This is what I have so far:

Private Sub Form_Timer()
If Me.ContractType = "CO" Then
Me.Const_Description.Visible = True
Else
Me.Const_Description.Visible = Not Me.Const_Description.Visible
End If
End Sub


I hope I made this easy to understand. Very new at Code.

Thanks

Joe

View 1 Replies View Related

I Am Stumped As To Why This Simple Code Won't Work...

Nov 2, 2006

Form: frmProduct
Field: unitprice.

I have some simple validation that unit price is greater than 0. The code is this:

If Me.txtUnitPrice.Value <= 0 Then
MsgBox "Please enter a value greater than zero", vbOKOnly, "Alert"
Me.txtUnitPrice.Value = Null
Me.txtUnitPrice.SetFocus
End If

However, when I run it, the setfocus doesn't work. It jumps straight into the next field. I can make it run to any other field (productname, productID). But not back to UnitPrice.

View 6 Replies View Related

Simple: How To Use This Code With Switchboard Button

Feb 3, 2005

I found this simple password code that I use to open some forms:
Code:Dim x As Stringx = "password"Dim y As Stringy = InputBox("Enter password for form")If x <> y ThenMsgBox ("Invalid password")DoCmd.CancelEventEnd If
I would like to use it in a switchboard button, but the following statement is
OnClick already "=HandleButtonClick(4)". How can I incorporate this statement
with the code?

(I guess I don't really understanding how the auto-switchboard works.)

As always...Thank You

View 4 Replies View Related

Quick Easy Question, RE Error With Simple Code

May 24, 2007

hiya every1, (access 2k3)

quick easy question, as im a noob when it comes to coding/vb.

Within our company database we have the usual timesheet table. With the table I have create a query (called "dailytimeforkeith") that gives me the sum of time for an individual person for one day (in fact its the previous day). What I have done then is created a form (called "keithyesterdaytime") that shows this query entry (called "sumoftimespent").

Each user has a different database screen logon and forms that are present when they log in. So what I then done is on one of these forms the load up, i attached this:

Private Sub Employee_Enter()

Me.Employee = User.FirstName


If Me.Employee = "Keith" Then

Dim stdocname As String

stdocname = "keithyesterdaytime"

DoCmd.OpenForm stdocname, , , acAdd

............



then on "keithyesterdaytime" opening the following code runs
------------------------------------------------------------

Private Sub Form_Open(Cancel As Integer)

Dim internal1 As Integer

internal1 = Forms!keithyesterdaytime.SumOfTimeSpent

If internal1 < 6 Then

DoCmd.Close

MsgBox " Less than 6 hours have been entered " & Chr(13) & " into your timesheet for yesterday. ", vbCritical, Title1

Else

DoCmd.Close

End If

End Sub
-------------------------------------------------------

Whenever i logon with the user keith, i get the following error 'runtime error 2427: You entered an expression that has no value.

If I open the form "keithyesterdaytime" on its own, the code works and i dont get an error.


What have i done wrong, and be gently. HEHEHE. Also is there any easy way i can do this instead of having to create the the form "keithyesterdaytime"

View 2 Replies View Related

Forms :: Code For Date Picker Use AND User Date Entry

Mar 26, 2015

I have a textbox on my form that is for "week of", always a Monday. There is vba to populate the appropriate Monday when the user selects something other than Monday via the date picker. This code is in the on change event. However, this is not friendly to a user entering a date in this field. I did try after update event, but that requires user to leave the "week of" field. This is not acceptable in this instance, there are other form fields that change as a result of this "week of" value.I also tried evaluating the length of the text or else exiting the code. However, I was expecting the date being returned from the date picker to always be 10 positions, but for March 3rd, it would return 3/3/2015...which is only 8 positions.

View 2 Replies View Related

None Working "simple Code" On Close Event?

May 16, 2006

I have witten a code in the close event of a "Primary" form that would update a Combo boxe on a "secondary" form only if the "secondary" form is open.
ie:

Private Sub Form_Close()
If Forms!frmEnquiry.Open Then
Forms!frmEnquiry!CboCustomer.Requery
Else
DoCmd.Close
End If
End Sub

This code keeps giving me an error, is anybody has got any idea why?
Thanks in advance.

View 7 Replies View Related

Simple Up-date Querry

Nov 20, 2007

hello all,
i would be extreemly grateful if anyone could offer me some help with this,, basically i have two tables containing the same fields,, one of the table has approx 3k entries where the other has approx 100 entries,, table two (the smaller table) has the same data the only difference being the percentage filed will have increased. for example Tabel 1 has JC111 at 10% and Table 2 has JC111 at 20%,, my life would be made so very much happier if i could find a method of running an up-date query that would take the 'new' % values from table 2 and post them into or create a new table that has the correct/new %'s.
i really hope this makes some sense,, i would appreciate anyones help
best regards

View 2 Replies View Related

Simple Date Solution...

Oct 3, 2006

Hi all,

Please forgive a newbie that asking the stupid question.... i just wonder is that anyway to set the date format to short date with instead of mm/dd/yyyy to dd/mm/yyyy to let the user to keyin?

Thanks alot.

View 3 Replies View Related

Error With Simple Date Entry!?!?

Jul 5, 2006

I got this to work easily on another form but on this particular form it doesnt work. I enter a command button and name it d1, then I enter this code for it to populate the current date in the field next to the box:

Private Sub d1_Click()
Date_Entered.Value = Date
End Sub

Can anyone see why it doesnt work :eek:

ERROR IS:
Run-time error '2465':

Database cant find the field 'Date' referred to in your expression.

When I enter a date field it enders whats in that field (blank) into the field I told it (Date_Entered) on my form.

View 3 Replies View Related

Date/Time Criteria- Simple, Right???

Sep 13, 2006

OK... what am I forgetting?

I have a linked SQL table with a Date/Time field called DATE. ALL I WANT TO DO is pluck all the records with a single date from that table.

Predictibly, the date field has values like this:
9/11/2006 12:40:46 PM

If in the MS-Access query I use criteria of #9/11/2006# I get other dates also. I have tried variations on Date() or DatePart but those either fail or don't work. Sheesh.

ULTIMATELY, I want to restrict records to a specific date, and then a certain hour of that date, so if you can include this bit of additional logic in your response, that'd be great too. Note: I am trying to structure a query, not write code.

Thanks!

View 2 Replies View Related

Simple Error Trapping By Error Code

Dec 6, 2005

hi all

i have the following peice of code ...


Private Sub NextApplication_Click()
On Error GoTo Err_NextApplication_Click
DoCmd.GoToRecord , , acNext

Exit_NextApplication_Click:
Exit Sub

Err_NextApplication_Click:
If Err.Number = 2105 Then
MsgBox "Cannot navigate to the next record. This is the last record."
Else
MsgBox Err.Description
End If

Resume Exit_NextApplication_Click

End Sub


but even when this error occurs nothing is being properly handled the way i specified - any ideas ?

View 3 Replies View Related

Please Help Out A Silly Prat With A Simple Date Question

Sep 16, 2005

I have the following fields in a query: "Employee_number", "shiftname", and "shiftdate"
And I have the following code on the criteria of "shiftdate": >= dateadd("d",-7,Date()) so that only records from the past 7 days are displayed which is fine, however when I run the query it displays the following

Employee_numbershiftnameshiftdate
1A16/09/2005
2A16/09/2005
3B15/09/2005
4B15/09/2005

which is not quite what i want.....Is it possible to make it only show the same shiftname with the same shiftdate just the once instead of showing it several times for each employee?

View 4 Replies View Related

Hard Code TIME To Selected Date On Form (to Make It Date&time) For My Query Criteria

Aug 17, 2006

Hello buddies :D, do you have any idea how to make this work?

To select data that falls within this criteria of date range between cboDate and cboDate2 (fields on my form). The date in [tblJobDetails]![timeIn] come in this format "08/17/06 10:24 AM", but the cboDate/cboDate2 (takes in date only e.g 08/17/06) what i am after is to evaluate specific hard coded time in addition to the date entered, i.e. even tho, i haven't entered time on the cboDate/cboDate2, I want specific time hard coded where e.g If i select a date range of 08/17/06 and 08/18/06 on my cboDate and cboDate2 it should really be evaluating: 08/17/06 8:00 AM to 08/18/06 8:00 AM.

This is the criteria i curentlly have on my query in design view tha works perfect in selecting date only.
([tblJobDetails]![timeIn]>=[Forms]![frmPendingJobs]![cboDate] Or [tblJobDetails]![timeIn]>=[Forms]![frmPendingJobs]![cboDate] Is Null) And ([tblJobDetails]![timeIn]<=[Forms]![frmPendingJobs]![cboDate2] Or [tblJobDetails]![timeIn]<=[Forms]![frmPendingJobs]![cboDate2] Is Null)
How can I incorporate 8:00am to 8:00am into my cboDate and cboDate2. What can i do to make this happen? Your kindness will be greatly appreciated http://www.naijaryders.com/forums/images/smilies/thankyou.gif

View 10 Replies View Related

Table With Autonumber And Need Date Code

Mar 15, 2007

I have a table named tblProjectNumber that has a autonumber field. In design view under the format property I have "NC07-"00000, this returns the a new project number with the text in front of it. What I would really want is for the text the change dynamically with the year. So an example would be NC07-00000 for project numbers created this year but I will manually have to change it for next year and the all of the previous project numbers will change accordingly. I have tried "DateSerial(Year(Date())-"00000 , Date("yy") and I can't get it tto work.Any help would be great.

Tim

View 1 Replies View Related

Automatic Date Function With Code

Aug 13, 2004

I have a date field (WhitesDue) that I want automatically filled in when information in another field (Conditions) in another table is entered. The field Conditions is a number field and depending on the number of conditions determines when the whites are due.

I saw the other thread, Automatic Date Function, and was wondering if it was possible to put an if then code in to have the date updated with different dates depending on the number of conditions and the date that the information is put in. For example if someone is putting information in today and they have 4 conditions then I want the date to be automatically filled in with 8/17/04 (is it possible to factor weekends in too?).

Does that make sense? Can anyone help me out here?


Okay I stepped through some code that I have in the Conditions after update event. It works, it puts the date in the code like it is supposed to. Now, how do I get it to put the date into a field on another form?

If [Conditions] > 3 And [Conditions] < 5 Then
[Whites] = Now + 2
ElseIf [Conditions] > 5 Then
[Whites] = Now + 4
Else
[Whites] = Now + 1
End If

learnasugo

View 9 Replies View Related

How Do I Create A Date Code In A Form?

Jan 17, 2005

I have a date field set up in my form but I want to be able to make a numberical entry of 010105 and it convert to 01/01/2005. How do I do this?

View 2 Replies View Related

Queries :: SQL Code For Displaying Max Date

Apr 13, 2015

I need displaying the max date sql code below;

PHP Code:

SELECT TblDietPlan.DietPlanID, TblDietPlan.ClientID, TblDietPlan.MealDate, TblDietPlan.MorningSnack, 
TblDietPlan.AfternoonSnack, TblDietPlan.EveningSnack
FROM TblDietPlan
WHERE (((TblDietPlan.ClientID) Is Not Null) AND ((TblDietPlan.MealDate)=Max()))
ORDER BY TblDietPlan.MealDate DESC; 

View 4 Replies View Related

Modules & VBA :: Inset Date Add Code To SQL String

May 22, 2015

I am trying to add 30 or 45 days to a certain date and insert that date in a table. The field is declared as datetime on the SQLServer and has been tried with all date formats, and none, on the access side.The problem I am encountering is that the date is being inserted as 12:00:00 in the table, no date is being stored.When I print out the SQL statement to the immediate window, the date in question shows the correct date.

Code:

Dim a As Date
Dim b As Date
a = DateAdd("d", 45, Me.DateOfExit)
b = DateAdd("d", 30, Me.DateOfExit)
strSQL = "INSERT INTO MyTable ( No, Name,DueDate, OriginatedBy, ID, Status) " & vbCrLf & _
"VALUES (" & Me.No & ",'" & Me.Name & "', " & b & ", '" & Me.Facilitator & "', " & Me.ID & ", '" & "Required" & "');"

I have tried adding the date add code to the SQL string, but that produced the same result.

View 4 Replies View Related

Simple Question For A Simple DB

Dec 29, 2006

Ok I am right now making a simple Vendor/Product database to create a line sheet for some sales folks. I have 3 tables: Vendors, Products, and an associate entity Vendors_Products to relate the two. I have a form currently that draws the Vendor Name (primary key) from the Vendor table and the Product Name from the associate entity. This allows me to create new vendors and select current product types from a drop down box. The problem is that the drop down box is too long and it is tiresome when 1 vendor has 10 product types.

Can anyone tell me how to resolve this? I thought it would be better to have option buttons and display all available products. Then you could just click all of the option buttons that apply to that Vendor and it would create the relationships...is this possible?

View 1 Replies View Related

Using Code To Unprotect And Protect Viewing Code

Jan 14, 2007

I protect my code from people being able to read it by setting a password on the code from Tools > Properties, selecting the Protection tab and entering a password, and clicking "Lock Project"

Is there a way to write code that will remove that Lock Project check and check it back on?

I've looked through the Application.SetOption command and it doesn't seem to be one of the choices. It would be very helpful if someone knew how to do this.

Thanks

SHADOW

View 6 Replies View Related

Queries :: Date / Time Query - Return All Records Of Specified Date Or Date Range

Aug 19, 2015

I have a table that has entries recorded with date and time in one field, and I want to have a query that returns all records of a specified date or date range, regardless of the time in the field.

I have tried

Code:
Between [StartDate:] And [EndDate:]

And

Code:
Between [StartDate:] & "00:00" And [EndDate:] & "23:59"

Neither of which work ....

View 13 Replies View Related







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