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

Simple Calculation Won't Work?

Jan 19, 2005

I have been designing my first database and am just about ready to finish my first report. I have created a text box and added the following to the box =myfield1+myfield2+myfield3+myfield4

I created this through the expression builder so I know the fields a correct but now the calculation is not working. I don't get any calculation in the box except a "0". Why isn't this calculation giving me the sum of these 4 fields?

Please please help.....

View 8 Replies View Related

Can Not Get Code To Work.

Sep 9, 2006

Hi, can someone help me with this code I do not get a return ( 5 ) or ( 10 ) ( 15 ).
Anyone have a solution,any help would be appreciated.

Private Sub cust_credit_score_1_AfterUpdate()

If [Forms]![test credit]![cust_credit_reply_1] = " [Bad Credit]" Then
[Forms]![test credit]![cust_credit_score_1] = 5

Else

If [Forms]![test credit]![cust_credit_reply_1] = " [Poor Credit]" Then
[Forms]![test credit]![cust_credit_score_1] = 10

Else

[Forms]![test credit]![cust_credit_score_1] = 15

End If

End If
End Sub

Thank You John527

View 7 Replies View Related

Functions Work In Code But Not Queries

Feb 14, 2007

I have a problem where I can create queries in code using functions such as Left() and they will work fine on my clients machines with a complied MDE file but if I try to use the same function in a saved querie they get an error: "Function is not available in expressions in query expression..."

The Queries work fine on my machine but not on those using Access Runtime. From my research it appears to be a problem with them not having the correct Reference on their machine. If that is true then which Reference do they need and is there away of installing that Reference by code?

Thanks for your help....

View 1 Replies View Related

General Q - Code And Why It Doesnt Work All Of The Time

Feb 6, 2008

I am wondering why access does not follow its own code all of the time?

For example I have passworded forms following the tutorial on the Microsoft site. It mostly works when the participants fills in the wrong password we will get an error message box and when they cancel the password dialogue box it wont let the person enter the form - but not all the time. Sometimes if you press cancel it still opens the form anyway (without requiring the correct password).

This is similar with the module that I put in to prevent people from using the mousewheel to leave their record etc. Most times it works but sometimes it just isnt called on form load.

There is nothing wrong with any of these codes and when they work they work well but I cant seem to rely on access to do what is supposed to?

View 1 Replies View Related

Tabbed Pages - Code Doesn't Seem To Work

Nov 13, 2006

I'm using a 5-tabbed form and have put it in my detail section.
Within the on click event of one tab knob i would like to activate some knobs in the form header where the tab resides on.

I've coded everything properly but in one or other way access doesn't seem to communicate between the tabbed form within the details and the form header. Anybody an idea?

View 4 Replies View Related

Modules & VBA :: Repaint Doesn't Work Until End Of Code

Jul 31, 2015

I have a process which runs lots of slow append queries, so I want to reassure the user of progress, by changing the font colour of labels to green when the relevant queries have finished. This is the code I'm using

Code:
'Update the older data if that option is selected
If Me.Menu_YearOption.Value = 1 Then
DoCmd.OpenQuery "2-10 Append FY1112"
Me.lbl1112.ForeColor = 32768
Me.Repaint
DoCmd.OpenQuery "2-12 Append FY1213"

[Code]...

Each query takes about a minute to run, as it gets data from a sharepoint server, but the labels don't turn green one at a time as expected. Instead, I get the spinning wheel until all the queries have run, then all the labels turn green together.

Is there something else I should be doing rather than Me.Repaint ?

View 11 Replies View Related

VBA Code Doesn't Work After Saving In ACCDE

Oct 2, 2014

I saved my front end db as .accde in order to distribute it without user being able to edit my objects. As it turned out, when I open the .accde now I see my code doesn't work anymore. I have a lot of startup code and now it doesn't trigger at startup. Basically all my forms use vba code and none of them works in .accde . Accdb version works without any issue.

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

General :: Break Points In Code Module Fail To Work

Oct 16, 2013

Does your Tools Reference have an MS Office 15.0 Object Library?

Just had to share this strange occurrence in the VB Code Module:

I use breakpoints all the time, was just using them yesterday.

Noticed that some events seemed to act differently this morning. The front-end was approaching 88 MB (after compress) so it is time for a change anyway.

Created a new blank Access dB (Access 2010) and imported all objects from my last backup revision. Reset the home page and tools References. Matched the settings side by side. As usual, the database shrank from 88 MB to 60 MB. The import all objects will usually compress things about this much.

From the screen shot, put breakpoints in previous code, added a new Lost-focus event and added a message box. None of the breakpoints work. The message box fires on the lost_focus and all of the code in the Click event works fine. But, not a single break point would work.

Totally powered down and restarted the Windows 7 32 bit Enterprise workstation. Still no change.

Took the screen shot of Tool-References from the code module of a two week old archive version. Used it to evaluate my new imported object database.To my surprise, the Microsoft Office 14.0 Object library is now Microsoft Office 15.0 Object Library.Also put all the objects back in the same order. Saved and closed the new imported object database.Now, the breakpoints work just fine.

I had failed to reference the Office 15 Object Library and the VBA Extensibility 5.Office 14 Object Library is nowhere to be found except on my 2 week old backup archive.

Is this a Microsoft auto update? Is this what drives the breakpoint in the code module?

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

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

I'm Stumped..

Aug 2, 2006

Hi,

I m trying to find a way of automatically inputting the progress of my project.. it's confusing so i'll try ot explain more. I have a project plan broken down into weeks . Each element of this has a schedule and complete date for various different milestones which indicate what week my project is sitting at:- eg: I have reached this milestone therefore my project is at week 10 and so on until completion.

Is there some query I can run that can do this automatically?

I'd be grateful for any help on this.

Thanks K

View 14 Replies View Related

I'm Stumped

Feb 17, 2005

hi all - i know there are many threads relating to linking pictures to records etc, but forgive me for asking one more time:

I have managed to get pictures into my dbase - using Microsoft KB help - by linking them in a table to an external source.

However, I want the dbase to know which picture is for what details. eg. I have a cars sales dbase. I have all the pictures in one folder of all my cars which are linked to the dbase. When I pull up car details in the form, I want the picture to come up aswell - the correct picture.

Pls let me know if this has been done. Sorry for extending this topic; however, I could not find a "simplish" soln. to this.
Thank you once again :o

View 4 Replies View Related

Stumped With Dates

Apr 25, 2008

I’ve developed a query that produces a list of forms and an effective date where the form may be applicable. But now I am stumped. I need to reduce the results to a specific state (which I’ve done and it works) and for a specific date (the stumped part). Let’s say user needs 2/15/2005. I think I can eliminate forms with effective dates greater than 2/15/2005 (not quite sure how yet) but I am perplexed how to eliminate certain forms that are no longer valid because they’ve been superceded. In the sample table for CA, I would expect the following forms retuned and no others: CG0001 1204; CG0002 1204; CG0009 1204; CG0033 10 01; CG0034 1204; and CG0035 1207. The expected results for the CT column would be different (though some would be the same).

Any advice to point me in the right direction would be appreciated.

FormNumForm_vdt CA CT
CG00010798 09/01/1999
CG0001100103/26/200102/01/2002
CG0001120407/13/200407/01/2005
CG0001120712/05/200712/01/2007
CG0002100103/26/200102/01/2002
CG0002120407/13/200407/01/2005
CG0002120712/05/200712/01/2007
CG0009100103/26/200102/01/2002
CG0009120407/13/200407/01/2005
CG0009120712/05/200712/01/2007
CG0033019603/26/200105/01/1996
CG0033100107/13/200402/01/2002
CG0033120412/05/200707/01/2005
CG0033120712/07/200712/01/2007
CG0034100103/26/200102/01/2002
CG0034120407/13/200407/01/2005
CG0035100112/05/200702/01/2002
CG0035120403/26/200107/01/2005
CG0035120707/13/200412/01/2007

View 2 Replies View Related

This Subform's Got Me Stumped...

May 18, 2005

I have a form with two subforms. One of the two subforms works perfectly. The other just gives me a grey screen (like there's no recordset).

The two forms are very similar and I've checked everything I can think of... Here's what I've done. If you can think of anything else to try, please let me know - This is driving me crazy!

1) The subform works independent of its parent
2) The source object for the subform is set properly
3) The child and master fields are set properly. Data types are the same.
4) The record source for the form (used as subform) is set to the correct query.
5) The query used has been run independently with no problems
6) The form has a bound text box with the proper control source
7) I've tried placing a breakpoint at the first line of form_current.. never gets hit.

I don't know why it's not working and there's nothing that tells me what/where the problem is. I'm out of ideas on this one.... Any help is greatly appreciated!

View 3 Replies View Related

Dlookup / Dcount ? Stumped!!!

Feb 10, 2005

Hi all,

I have a form with the following fields:-

StartTime = Format dd/mm/yyyy hh:nn:ss
ExpFinishTime = Format dd/mm/yyyy hh:nn:ss
Dentist = Number

StartTime is bound to my table, ExpFinishTime is calculated in the forms underlying query.

Before the record updates I am trying to check if anyone already has an appointment scheduled in during that particular time for that particular dentist. So if the record being added has a starttime between those two times for that dentist, throw up a message box.

Thanks for any help.

Taff

View 5 Replies View Related

Stumped. Table Relationship / Normalization

Apr 25, 2005

I am having trouble visualizing how to break out the following info into functional Tables

I have a table to hold Items

tblListG1Items
IDItemList
ITemNumber
ItemName

I then have a detail table

tblDetailG1Items
IDItemDetail
FKToItemList
ItemMFG
ItemMSP
ItemLead

Here is where I get lost.
Each item has a variable for each month
So item 1
January = .01
February = .03
ECT.
Once set the Variables rarely change, at most once per year.

I will need to be able to pull an item and based on what month it is pulled uses the variable to multiply several other factures.

My first Thought was,

tblVarItemList
IDVarList
FKToItemList
VarJanF
VarFebF
VarMarF
--And so on--

It just does not look right.
Any Suggestions on what might work Better. :confused:

View 6 Replies View Related

Mildly Stumped League Tables,

Jun 3, 2005

I've been asked to collate some information based on a kid league, I am trying to sort out how precisely it works

the data I have is this

finish position, name, club

I need to calculate the best kiddie based on 3 of a possible 6 races

So tbls

tblResults
fldSeries
NAME
CLUB
Pos(isition)

tblScores
fldID
pos
Points

query1
SELECT tblResults.fldSeries, tblResults.NAME, tblResults.CLUB, Sum(fldScore.Points) AS SumOfPoints
FROM tblResults LEFT JOIN fldScore ON tblResults.Pos = fldScore.Pos
GROUP BY tblResults.fldSeries, tblResults.NAME, tblResults.CLUB, tblResults.Pos
HAVING (((tblResults.fldSeries)="220-2005") AND ((tblResults.Pos)<51))
ORDER BY Sum(fldScore.Points) DESC;

I need this to be changed to only pick up athletes with only the best three scores?

any hints?

STuart

View 3 Replies View Related

Crazy Data Problem “I Am Stumped”

Mar 27, 2008

Hello,
When I try to run any query that contains a specific table I get a message a Not enough memory error. I can open that table which, contains 47 thousand records and view that data unless I get to one record then the entire database crashes. I have tried to Compress and Repair and the database crashes. When I say crash I means it completely disappears and I get the send error to Microsoft Message. I can not select record due to it crashes when I get to it. I have also tried selecting record by going to one above the quickly scrolling to a record way below it and it errors and crashes. I have tried to delete it using a delete query and it only returns “Invalid argument” when I try to select or delete.

ANY suggestions or ideas would be greatly appreciated.

View 10 Replies View Related

Search Code Work On One Form But Not The Other Form?

Jul 18, 2015

* This code works to search frmMember for criteria found in tblMember:

Private Sub cmdSearch_Click()
If Len(cboSearchField) = 0 Or IsNull(cboSearchField) = True Then
MsgBox "You must select a field to search."
ElseIf Len(txtSearchString) = 0 Or IsNull(txtSearchString) = True Then
MsgBox "You must enter a search string."

[Code] ....

* But this next code which I have copied and Pasted to frmEventInput, then renamed the frm and tbl, retrieves the same criteria as the above (tblMember) instead of the tblEventInfo...

Private Sub cmdSearch_Click()
If Len(cboSearchField) = 0 Or IsNull(cboSearchField) = True Then
MsgBox "You must select a field to search."
ElseIf Len(txtSearchString) = 0 Or IsNull(txtSearchString) = True Then
MsgBox "You must enter a search string."

[code]...

What am I missing?

View 3 Replies View Related







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