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
------------------------------------------------------------
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
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 ?
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?
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.
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:
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?
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
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....
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.
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.
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.
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.
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.
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.)
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:
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.
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
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.
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?
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.
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