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 Replies


ADVERTISEMENT

Quick And Easy One

Jun 20, 2006

HI

I am creating this bloody db and I have created a form and when I open it, it shows, record no one, what I want it to do is open blank ready for a new bit of info to be put in. I know this is an easy one but im sick of the sight of access this week

With thanks

View 5 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

Quick Easy Question

Nov 29, 2004

But not easy for me, as its been years since ive done this kinda stuff. I got a field called 'CreditCard#' in a table called Customer. The data type of this field, i've set to 'Number' but how do i format it so it only allows the user to enter in a 16 digit number?

View 2 Replies View Related

Quick Easy Answer Needed

Sep 28, 2006

Text field

"CM#000001"

How do i write a where criteria to exclude all records that start with "CM#"

like "CM#*" does not work

like 'CM#' & "*" does not work

thanks

sportsguy

View 3 Replies View Related

!!!changing Font Colour - Simple Question, Quick Response Required If Possible!!!

Feb 14, 2006

i have a text box which displays the current stock level of an item, when the current stock level reaches 1 i need the font to change colour from black to red.
for example, if the stock is 2 - font is black
if one item is sold the stock will become 1 - font changes to red

how do i go about this? any help is VERY VERY welcomed and muchly appreciated. thanx alot.

View 2 Replies View Related

Need Help Creating A Simple Query. Easy For Any Of You. Pls Help

Jun 14, 2004

Hi,
I don't know how to create a simple query that will compare 2 tables and create a new one after that.
Each table has only one field.

Example:

Table 1 has records A, B, C, D and E
Table 2 has records A and C

I want new table to be like table 1 minus table 2. Like cleaning up table 1.
New table would have records B, D and E

I think it's very simple but I can figure how to do it.

Could you pls give me advice?

Thanks a lot,

skuba

View 3 Replies View Related

Simple Relationships Problem (easy For The Experts)

Feb 18, 2008

Hi there,

I'm creating a database for my computer repair business and it's going to store details on my customers, their computers, and any repairs I carry out on them.

I've created some tables, but I'm unable to create the relationships I require between the tables. Here's what I have:

http://img352.imageshack.us/img352/4724/helpbk3.jpg

I want to create a one-to-many relationship between the tables left to right, excluding the Engineer table, which I will talk about in a moment.

The idea is - One customer has "many" computers, one computer has "many" repairs, one repair has "many" problems. Each repair has just ONE engineer assigned to it, although the engineer will be assigned to many repairs.

I can link the Customer and Computer tables, via the CustomerID, but when I try to connect the other tables, I get the "Relationship Type: Indeterminate" error.

Can anyone help me with what fields I need in each table, and what relationships I need to achieve what I need?

Many thanks :)
Paul

View 2 Replies View Related

Code Help Easy Fix For The Gurus

Apr 19, 2006

the following works great, when I have text in the field. I want to do, is just the opposite

If Nz(Me.NTP) Then
Me.Label159.Visible = Not Me.Label159.Visible
Else
Me.Label159.Visible = True
End If
end sub

View 4 Replies View Related

Modules & VBA :: Quick Way To Export ALL VBA Code To A Text File / Word Document?

Aug 4, 2014

Is there a quick way to export ALL VBA code to a text file/word document?

View 5 Replies View Related

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

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 2 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

General :: Disk Or Network Error With Error Code 3043

Jul 13, 2012

How I can get rid of Disk or network error with error code 3043? What this error indicates.

View 4 Replies View Related

Simple Error

May 11, 2005

I am designing a table that will be used on a Form...thee will be a series of yes/no questions. I wanted to include a list box that the user adds one or the other. However i can't remember how to do it :D :confused:

All help gratefully received

View 5 Replies View Related

Error From Simple Statement

Jun 5, 2007

Okay, now I'm suspecting there's more to this than an overly complicated control source statement....

My summary report contains multiple objects that calculate totals based on a statement in their control source. The report ran fine for a few weeks but all of a sudden it started producing this error:

"The expression is typed incorrectly, or it is too complex to be evaluated. For example, a numeric expression may contain too many complicated elements. Try simplifying the expression by assigning parts of the expression to variables."

I thought perhaps that 12 lengthy control source statements were simply too much for Access to handle, but then I did some testing and eventually removed all but this control source statement: =Sum([NotifType]=9)

That's about as simple as it gets, but when I try and run the report I still get the error. Ggggrrrrrrrrr....

Can anyone tell me what causes this annoying error and how I can get rid of it? (I already compiled.) What little Access quirk am I running into? I will gladly zip the file and post if necessary.

Thank you.

View 10 Replies View Related

Simple Vb Error Problem

Apr 5, 2006

i'm not very good at vb and i'm sure this is an easy problem but i can't find the answer.
i have constructed a vb code to show images from a stored table [not OLE linked]:

Private Sub Form_Current()
If Not IsNull(Me.combined_image_path) Then
Me.cempic.Picture = Me.combined_image_path
End If
End Sub

this works fine except when there is no image to show, the last image stays visable. what i want is no image to show if no image is availiabe for that record.
i know that the statement should be constructed along the lines of
'then'
if no image exists then show nothing
'else'
Me.cempic.Picture = Me.combined_image_path

any ideas of what this procedure should be??

thanks

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

Simple Form Totalling Error

Sep 2, 2005

I am making a simple tabular form to use as a subform in another.

The form has a cbo box (cboItem_Name)
Quantity (txtQuantity)
Price (txtItem_Cost)
Extended Price (txtExtended_Price)

Selecting an item in the combo puts the price in txtItem_Cost. Default for Quantity is 1. Control Source for txtExtended_Price = [txtQuantity]*[txtItem_Cost] and gives me my extended price.

I have a control in the footer of the form called txtSub_Total. It's Control Source =SUM([txtExtended_Price]).
This Sub Total box generates the #error.

Can anyone tell me why? Do I need to do some other magic with my txtExtended_Price control instead of a simple calculation, like I have?

Thanks for any help you can give a novice.

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

Code Error

May 1, 2005

I can't get this working. The code was posted by someone else. Anybody that can help, thanks so much.
........................
I have a table name main1.
I have a form name main2. (input box and command button)

..........................I placed the code into my command button......

Private Sub Command2_Click()
Set con = Application.CurrentProject.Connection
Set rs = CreateObject("ADODB.Recordset")
stSql = "SELECT * FROM main1 "
'I have the password stored in this table!

rs.Open stSql, con, 1 ' 1 = adOpenKeyset

If Not (rs.EOF) Then
If rs![PASSWORD] = Form_main2.Text1.Value Then
'Text1 is my unbound box for the user to enter the password!
DoCmd.OpenForm "intro"
DoCmd.OpenForm "main2"
DoCmd.Close
Else
MsgBox "You have entered the wrong Password!"
End If
End If
End Sub

View 3 Replies View Related







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