Hi all,
I've got some code to write a record to a table but its got me confused, it works fine but instead of taking the values from the system its giving me popups to fill in the values manually. It should be taking userName, date and time from the system.
Any ideas what I've done wrong,
Here's the code? - Private Sub btnEngBook_Click()
-
-
Dim username As String
-
Dim jID As String
-
Dim Tvalue As String
-
Dim LDate As String
-
-
-
username = Nz(Forms!frmLogin!txtMembername, "")
-
jID = "job1"
-
Tvalue = Time
-
LDate = Date
-
-
Dim strSQL As String
-
strSQL = "INSERT INTO tblBooking(userID, jobID, startTime, startDate, bookingStatus) Values([username],[jID],[Tvalue],[LDate],[Active])"
-
DoCmd.RunSQL (strSQL)
-
-
-
End Sub
5 2390
Hi all,
I've got some code to write a record to a table but its got me confused, it works fine but instead of taking the values from the system its giving me popups to fill in the values manually. It should be taking userName, date and time from the system.
Any ideas what I've done wrong,
Here's the code?
Private Sub btnEngBook_Click()
Dim username As String
Dim jID As String
Dim Tvalue As String
Dim LDate As String
username = Nz(Forms!frmLogin!txtMembername, "")
jID = "job1"
Tvalue = Time
LDate = Date
Dim strSQL As String
strSQL = "INSERT INTO tblBooking(userID, jobID, startTime, startDate, bookingStatus) Values([username],[jID],[Tvalue],[LDate],[Active])"
DoCmd.RunSQL (strSQL)
End Sub
Hi. I wonder is this a direct paste of your code? It will not work as is. I don't see what [Active] is supposed to be and I will assume it is another variable not shown in your code: - Dim strSQL As String
-
strSQL = "INSERT INTO tblBooking(userID, jobID, startTime, startDate,bookingStatus) Values( " _
-
& username & "," & jID & ",'" & Tvalue & "','" & LDate & "'," & Active & ")"
-
DoCmd.RunSQL (strSQL)
Hi willakawill,
It is a direct paste of my script and I had missed the active variable from it, I pasted in what you posted which is still bringing up popups to ask for the parameters. Its a job booking sytem and I want the user to be able to just click book and it fill the record in automatically with userID, jobID, startTime, startDate and set jobStatus to active.
I've uploaded it to here so you can take a look http://www.celestepoker.com/Temp/jr_system.mdb . Its got a login script to start with so if you enter username as u1 and password as 00 then click "Create Booking" then "Book" you'll see what i'm tryin to achieve.
Hope you can help.
Oops. Forgot that this is Access - Dim strSQL As String
-
strSQL = "INSERT INTO tblBooking(userID, jobID, startTime, startDate,bookingStatus) Values( " _
-
& username & "," & jID & ",#" & Tvalue & "#,#" & LDate & "#," & Active & ")"
-
DoCmd.RunSQL (strSQL)
make sure that each of these variables contains a value.
Cheers for your help,
I got it working perfectly thanks to you.
Here's the solution just incase it'll help any other newbies like me - Dim username As String
-
Dim jID As String
-
Dim Tvalue As String
-
Dim LDate As String
-
Dim jobActive As String
-
-
username = Nz(Forms!frmLogin!txtMembername, "")
-
jID = "job1"
-
Tvalue = Time
-
LDate = Date
-
jobActive = "Active"
-
-
Dim strSQL As String
-
strSQL = "INSERT INTO tblBooking(userID, jobID, startTime, startDate,bookingStatus) Values( '" & username & "','" & jID & "',#" & Tvalue & "#,#" & LDate & "#,'" & jobActive & "')"
-
DoCmd.RunSQL (strSQL)
Cheers for your help,
I got it working perfectly thanks to you.
Here's the solution just incase it'll help any other newbies like me
Dim username As String
Dim jID As String
Dim Tvalue As String
Dim LDate As String
Dim jobActive As String
username = Nz(Forms!frmLogin!txtMembername, "")
jID = "job1"
Tvalue = Time
LDate = Date
jobActive = "Active"
Dim strSQL As String
strSQL = "INSERT INTO tblBooking(userID, jobID, startTime, startDate,bookingStatus) Values( '" & username & "','" & jID & "',#" & Tvalue & "#,#" & LDate & "#,'" & jobActive & "')"
DoCmd.RunSQL (strSQL)
You are very welcome. When you post code here place it within code tags because it makes it easier to read. Just highlight the text that represents your code and click on the # at the top of the submission box
Sign in to post your reply or Sign up for a free account.
Similar topics
by: Ian Davies |
last post by:
I have the following code which displays some some formatted text in my
browser. The problem is I need to create a text file and write the records
from this array into it. Does anyone know how to...
|
by: Matt Clepper |
last post by:
Ok - debated on posting this on SQL group but here goes...
I have a piece of ASP code (function #1) that creates a new SQLTransaction
(BeginTransaction) to and begins to write records to the...
|
by: Jeff Pritchard |
last post by:
I have an MDB that contains a single table. Checkweigher data is being
continuously written to this MDB from a dedicated workstation over a network
into the MDB on the server at the rate of about...
|
by: M. Schroeder |
last post by:
I use an Access-form to write into an external Oracle table via Oracle-ODBC
driver.
It is not a read-only connection, and batch autocommit mode set to "all
successful statements".
I can read...
|
by: Paul |
last post by:
I have an application that I am tryign to modify, I never wrote the
original so need help with my modifications.
Currently the app reads and writes to an Access database with one table
'pupils'...
|
by: darrel |
last post by:
Our production web site went down today. We discovered that it was because
the XML file we use to create the site navigation (most all of the controls
on every page rely on this XML file) was only...
|
by: Skybuck Flying |
last post by:
Hello,
This morning I had an idea how to write Scalable Software in general.
Unfortunately with Delphi 2007 it can't be done because it does not support
operating overloading for classes, or...
|
by: kcdoell |
last post by:
Good Morning:
I am using the following code to add new records to a table that is on my Sub Form. Below is the code that I placed in my Before Update event on my Sub Form:
Private Sub...
|
by: Chuck Cheeze |
last post by:
This might be in the wrong group, but...
Here is an example of my data:
entry_id cat_id
1 20
2 25
3 30
4 25
5 35
|
by: =?Utf-8?B?ZmhpbGxpcG8=?= |
last post by:
We have a code snippet that downloads data to Excel. it is writing row by
row. This causes a performance issue. Any ideas on how to speed this up will
be appreciated.
Please find below an...
|
by: taylorcarr |
last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
|
by: Charles Arthur |
last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
|
by: aa123db |
last post by:
Variable and constants
Use var or let for variables and const fror constants.
Var foo ='bar';
Let foo ='bar';const baz ='bar';
Functions
function $name$ ($parameters$) {
}
...
|
by: ryjfgjl |
last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
|
by: nemocccc |
last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
|
by: Hystou |
last post by:
There are some requirements for setting up RAID:
1. The motherboard and BIOS support RAID configuration.
2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
|
by: marktang |
last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
|
by: Hystou |
last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
|
by: jinu1996 |
last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
| |