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 Replies


ADVERTISEMENT

Simple Coding Help Required

Jun 24, 2005

hi. I am trying to write a code to sum the total cost of all jobs that are selected as 'yes' in a combo box.

Once the user selects 'yes' in a combo box, they enter in a cost for that specific job. Each client may have 10s of jobs. I need to write a code that will sum up all the 'yes' selected jobs for a client. I know it should be an 'if' statement but I can't seem to get it to work. I need this value for a report. How would I do this and where would i put the code.

Help is appreciated.

View 1 Replies View Related

Required Field... Simple

Jun 23, 2005

I can not for the life of me figure out how to make one field required. The name of the field on the form is Selectee. Can someone help?

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

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

Forms :: Adding Onbeforeupdate Vb Code To Account For Missing Required Fields

Apr 4, 2014

I need code that I can incorporate with the code below, that will notify a user when required fields are left blank so that they have to go back and fill it in before updating the record. Below are the objects (shown in the order they appear on the form):

cmbModel
txtSerialNo
txtExpDate
txtPONo
cmbOfficeLoc

If any of the objects above are empty, the user should be prompted to go back and fill them in setting the focus back to the first empty object (again the fields above are in order). If conditions are not met, do not run the code below. If the conditions are met then proceed with the code below.

Private Sub Form_BeforeUpdate(Cancel As Integer)
Dim strMsg As String
Dim iResponse As Integer

' Specify the message to display.
strMsg = "Do you wish to save the changes?" & Chr(10)
strMsg = strMsg & "Click Yes to Save or No to Discard changes."

[Code] ......

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

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

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

Code To Change "Required" Field

Jan 12, 2005

I need to change the required field in a table to "No" to allow a refresh in a form, and then back to "Yes".

Anyone point me in the right direction?

low intermediate level of knowledge i guess.

Damon

View 2 Replies View Related

Forms :: Fields Are Required To Be Filled Out Even Though Not Set As Required

Nov 3, 2014

I have made a form based on related tables. it requires me to fill out every field, which I don't want. I didn't make them required. Why does it do that?

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

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

Help Required

Jul 26, 2007

Commission: IIf([Amt]<=10000,30), IIf(Int([Amt]/1000 Between 10000 And 50001)*3.5+3.75)

What I required to do is that when amount is greater than or equal to 10000 than Amt multiply by 30 simply.
and when amount is between 10000to 50001 than Amt/1000 multiply by 3.5+3.75

means that when amount is 15000 than according to per 1000 it will be calculated.

please dear help me out in this I required it very very urgently.

Please Please Please Please. ....................................

View 1 Replies View Related

Help Required !!!!!

Apr 4, 2005

Hi All,

I am new to Access and trying to create a database for employee's leave record.

I created table 1 for departments i.e., A, B, C and so on

There is table 2 for employees i.e., Z, X, Y and linked with table 1 for their departments.

There is table 3 where first I have to select department (from table 1) and then employee (table 2).

All I want (in table 3) is:

Once I select department, the next field for employee show its respective employees.

Thanks is advance.

View 1 Replies View Related

Help Required

Feb 24, 2008

I am fairly new to Access and may very well be trying to walk before I can run.

I have an Excel Spreadsheet that is currently used to produce a Nominal Roll that is listed by the following:


Surname
Enlisted Month
Enlisted Year

POP Month
POP Year

I know how to transfer it across to Access.



I then need to be able to produce lists (The listings order needs to be Enlisted Month/Year then POP Month/Year) that can then be merged into tables 4 columns wide (where at the top of each table is a General Comment) and the names run down in alphabetical order then move across to the next column.
(Basically for example I have 24 names that needs to be divided by 4)

hopefully that is as clear as mud, any help would be greatly appriciated

View 4 Replies View Related

Normalisation Help Required

Feb 25, 2006

Hi all this is my first post so go easy

OK i have a project to do about a garage


these are the unormalised attributes

Customer_ID, First_Name, Surname, Address, Telephone_No, Postcode, Employee_ID, First_Name, Surname, Hours_worked, Service_ID, Name_of_service, Cost_of_service, Car_registraion, Engine_size, Colour_of_Car, Car_manufacturer, Invoice_No, Amount_due, Amount_paid, Outstanding_amount, VAT, Cost_of_service, Booking_code, Date_of_booking

these are the entities

CUSTOMER
SERVICE
CAR
PAYMENT
EMPLOYEE
BOOKING

ive never done normalisation before, and read online a bit about it but cant for the life of me understand it. anyone willing to give me a little help. on converting the above to 1NF, 2NF and 3NF?

Thanks in advance
alison
x

View 2 Replies View Related

Required Field

May 8, 2006

Hi. I want to have all my fields on my form to be required and so that the user cant close the form if they are empty (error message). In the table properties I have them set to Required an have tried putting in a validation rule of IS NOT NULL but it still dont work. any help appreciated. thanks

View 1 Replies View Related

Access Required?

Nov 19, 2006

First of all sorry for the stupid question. I am opening a new business and will recieve a specializes CMS system using Access as the DB. Do I have to buy Access to run it?

View 2 Replies View Related

How To Set The Required Property Via SQL

Aug 1, 2005

How do I set the Required property for field that already exists via SQL. I'm thinking along the lines of: ALTER TABLE table1 ALTER COLUMN field1 text(50) NOT REQUIRED.

But this doesn't work, any clues?

View 5 Replies View Related







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