Forms :: VBA INSERT Query

Aug 15, 2014

how I can use this INSERT query to insert the value of max_hoeveelheid_contract into the "AS Expr7" part (end of the strQuery)

Code:
Dim max_hoeveelheid_contract As String
max_hoeveelheid_contract = som_hoeveelheid_NettoGewicht -Me.Hoeveelheid.Value
Dim strQuery As String

[code]....

View Replies


ADVERTISEMENT

Using RecordSet To Insert New Data Into A Query Based On Two Forms

Feb 25, 2007

This forum has been so useful to me so far... but having searched through a load of topics for a few hours now I just cannot find a correct method of having the ability to update two tables from a form.

I firstly created a query that selected the nessary fields I wish to update from the two tables.

And its apparent that I need to use RecordSet to insert the information from the form into the query.

I have found a few different ways of doing this - none of which work for me :( HELP!

Method 1
Private Sub Save_Record_Click()
'Save all entered information to tblprocess request and tblBackupRequest

Dim db As DAO.Database
Dim rs As DAO.Recordset


messageusr = MsgBox("Save this infomation?", vbYesNo + vbExclamation, "Warning you are about to Save this information")
If messageusr = vbYes Then

Set db = CurrentDb()
Set rs = db.OpenRecordset("SELECT .Server, [Backup Request].Location, [Backup Request].BackupType, [Process General].Type, [Backup Request].[Size(GB)], [Process General].Group, [Process General].[Date required by], [Process General].[Requested by], [Process General].[Date/Time of request], [Process General].Notes FROM [Process General] INNER JOIN [Backup Request] ON [Process General].ProcessID = [Backup Request].ProcessID;")

Me.txtserver = rs!Server
Me.cmblocation = rs!Location
Me.cmbtype = rs!BackupType
Me.cmbtype = rs!Type
Me.cmbsize = rs!Size(GB)
Me.cmbassign = rs!Group
Me.txtrequiredby = rs!Date_required_by
Me.txtrequestedby = rs!Requested_by
Me.txtrequest = rs!Date_Time_Request
Me.txtnotes = rs!Notes

'Clear fields on form to indicate write has occurred
txtserver = ""
cmblocation = ""
cmbtype = ""
cmbsize = ""
cmbassign = ""
txtrequiredby = ""
txtrequestedby = ""
txtrequest = ""
txtnotes = ""

'Close recordset and database
rs.Close
db.Close
MsgBox "This information has been succesfully saved"
End 'return user back to form
End If

End Sub

[B]Method 2
Private Sub Save_Record_Click()
'Save all entered information to tblprocess request and tblBackupRequest

Dim db As DAO.Database
Dim sqlStatement As String
Dim saverecord As DAO.Recordset

messageusr = MsgBox("Save this infomation?", vbYesNo + vbExclamation, "Warning you are about to Save this information")
If messageusr = vbYes Then

sqlStatement = "SELECT .Server, [Backup Request].Location, [Backup Request].BackupType, [Process General].Type, [Backup Request].[Size(GB)], [Process General].Group, [Process General].[Date required by], [Process General].[Requested by], [Process General].[Date/Time of request], [Process General].Notes FROM [Process General] INNER JOIN [Backup Request] ON [Process General].ProcessID = [Backup Request].ProcessID;"

Set db = CurrentDb()
Set saverecord = db.OpenRecordset(sqlStatement)


saverecord.AddNew
saverecord(0) = txtserver
saverecord(1) = cmblocation
saverecord(2) = cmbtype
saverecord(3) = cmbtype
saverecord(4) = cmbsize
saverecord(5) = cmbassign
saverecord(6) = txtrequiredby
saverecord(7) = txtrequestedby
saverecord(8) = txtrequest
saverecord(9) = txtnotes
saverecord.Update 'Write new record to database

'Clear fields on form to indicate write has occurred
txtserver = ""
cmblocation = ""
cmbtype = ""
cmbsize = ""
cmbassign = ""
txtrequiredby = ""
txtrequestedby = ""
txtrequest = ""
txtnotes = ""

'Close recordset and database
saverecord.Close
db.Close
MsgBox "This information has been succesfully saved"
End 'return user back to form
End If

End Sub

and I have even looked into an insert sql statement
[B]Method 3
Dim SQL_Text As String
SQL_Text = "INSERT INTO Backup Request (Server, Location, Type , Size(GB)) VALUES ('#Backup Request.txtserver#','#Backup Request.txtserver#','#Backup Request.txtserver#','#Backup Request.txtserver#') &"
INSERT INTO Process General (Group, Date required by, Requested by, Date/Time of request, General_Type, Notes;"
Docmd.RunSQL (SQL_Text, false)

Method 1 seems to be popular but its returning the message
Run time error '3061'
Too few parameters. Expected 3.
:confused:

View 14 Replies View Related

INSERT Query - Insert New Data Only

Jul 2, 2010

Table TBL_NEWDATA is used to append new data to table TBL_PERSON_ALLOCATIONS.

TBL_NEWDATA { Person_ID, Department_ID }
TBL_PERSON_ALLOCATIONS { Person_ID, Department_ID, ... }

I need to devise a query to append data for a particular Department_ID from TBL_NEWDATA to TBL_PERSON_ALLOCATIONS where that data does not already exist there. i.e. for Department_ID 'Research', I would want to append 'Person_ID', 'Department_ID' (in this case: 'Research') to TBL_PERSON_ALLOCATIONS for any tuples not already held.

INSERT INTO TBL_PERSON_ALLOCATIONS (Person_ID, Department_ID)
SELECT Person_ID, Department_ID
FROM TBL_NEWDATA
WHERE TBL_NEWDATA.Department_ID='Form...'

[code]...

This Query takes a single argument from a control (Forms!Main!IN_Department), and this is the Department_ID to be updated.Is there any way to do this using a single query or will I have to use sub queries? I'd hoped not to as to keep the database as concise as possible.

View 2 Replies View Related

Tables :: Use Insert Into Command To Insert Filepath Into Table That Adds Blank Label

Aug 28, 2014

I am at work, and I have acquired a database that prints labels. They now want the database to be coded so that after certain labels are printed the database will print a blank label. I have the code figured out as a Do While statement in order to print the blank label. The problem I am having is that I am trying to use the Insert Into command to insert the filepath into the table that adds the blank label.

|DoCmd.RunSQL "INSERT INTO Rod_tmakLabels ( Print, [Order] ) SELECT Yes AS Expr1, 'Rods Labels' AS Expr2"|

If I run the above command, it just adds the text "Rods Labels" at the end of the table. Is there anyway with the INSERT INTO command that I can insert the new label between the 2nd and 3rd row and add another row? Or is the command designed only to add a new row to the end? I haven't had any luck searching for this yet.

View 1 Replies View Related

Queries :: How To Insert A Prompt For Number In A Query To Calculate Against Another Field In Query

Jul 15, 2014

I have a field that is giving me the number of business days between a period of time and then I want to subtract that number - the person's PTO time to see the actual days they were available...when I simply type the number in (see below) it works great but I want to set up a prompt that will ask me how many PTO Days to calculate as it will be different for each person I am quering...is this possible?

View 9 Replies View Related

Queries :: Query To Insert Missing Rows From Another Query / Table

Oct 8, 2013

I am using an Access 2010 DB to keep track of a schedule. Essentially, at least one person needs to be signed up to work for every hour of every day in a week.

Tables:
Days with 7 records
Hours with 24 records
Workers with as many people that sign up to work the different hours
Schedule signifying the worker, day, and hour which are signed up.

As of now i have a query that relates these results and gives me a line detailing the worker/time information for the slots that are signed up for.What I'm TRYING to do is to create a query that gives me BLANK worker info when there is no one signed up for a particular hour.Currently my Schedule table has the following:

WorkerID | DayID | HourID
----------+---------+--------
1 | 5 | 12
4 | 5 | 13
16 | 5 | 15


What I'm looking to do is have this table matched up with another table (or query) that provides every combination of day/hour. When an day/hour combination is skipped, the query will be able to "fill in the blank" with a row. Like this:

WorkerID | DayID | HourID
----------+---------+--------
1 | 5 | 12
4 | 5 | 13
| | 14
16 | 5 | 15

View 2 Replies View Related

Queries :: Insert From A Query To A Table When Query Is Changed

Jul 10, 2015

I work with access web database. In access web aggregate functions are disabled in query design. So I made a query in client and i thought then i can insert this data to another web table. but i don't know how to update this table.

Because the source table of the query is also updated.

I upload the database with a table in it and a query. I want to add the data of this query to another web table....

View 1 Replies View Related

Forms :: Insert Date Into Form

Oct 26, 2014

i have just started to use access and i know how to insert the current date into a field using date() but i am not sure will this change the date everytime i open the form ? i want to create a form for invoices that shows the date the invoice was created and doesnt change if i re open for editing,

Ads: Technewonline is a website that specializes in introducing the latest technologies such as Best Tablet Android Have Price Under $200 and Best tablet of Apple in 2014 and The Best Midrange Smart Phone In 2014 and Top Best Ultrabook Of 2014 and The Best Phones 4G Valued At Under 300 USD is also a website for sharing your tips about computers, mobile phones and tablets, products are available from leading supermarkets will surely satisfy you.

View 1 Replies View Related

Forms :: Automatically Insert Object To OLE

Apr 10, 2014

I have Ms Access table with OLE Object column. So I am using form to handle this table. I want to store word documents in this column. Now, to add new item I should right click on OLE field, then choose "Insert object", then choose Microsoft Word Document.

How can I to automate this process? How can I automatically insert empty word document on adding new item?

View 1 Replies View Related

Forms :: Insert Data Into Another Form

Oct 3, 2013

I have a combo box Customer_Name on Order Form; and I want it open the Customer Form when an user insert a new customer to input all data. This seems simple at first, but problems are these:

1- whenever an user opens Customer Form on a new customer, the user would have to make the input once again (at least retype the customer's name on the field).

2- since the Customer_Name and other fields are required in the table, the Order_form would not allow the user to close it unless all field are filled properly.

Dilemma is you have to fill in the Customer_Name field before the table refresh all records and display it in the combo box on Order Form

View 13 Replies View Related

Forms :: How To Write Insert Statement

Jul 31, 2014

The row source for the combo-box is

SELECT tbl_p.P_ID, [plast] & " , " & [pFirst] AS Expr1 FROM tbl_p ORDER BY [plast] & " , " & [pFirst];

If notinlist I would like to add the the new name, how should I write the INSERT Statement?

View 1 Replies View Related

Forms :: Insert Page Numbering In Form

Feb 17, 2015

I want to add a page number to a form in MS Access 2010. How do I do this ? There is no page number icon in the control group when I'm in design view.

View 1 Replies View Related

Forms :: Insert Previous Balance Into New Record

Jan 2, 2014

i am using this query to insert the previouse balance into arrears as shown in the figure. it will insert some record correct and some are not correct.

SELECT fees.[gr no], sum((Admission+Registration+Fees.Tuition+[Fine]+Fees.Transport+[Exam]+[Misc])-Fees.Paid) AS bala
FROM fees
WHERE fees.balance<=0 and [gr no]=[gr no]
GROUP BY [gr no];

View 2 Replies View Related

Forms :: Go To End Of Field And Insert New Line And Date

Jan 2, 2014

I have set up a customer database for our small electronics company and i have built a form called contact history. In the form i show a few details about the customer (name phone number etc) but the bulk of the form is a large text box for a contact log.I would like to have a button on the form that takes me to the contact log field, inserts todays date and allows me to update whats been said to the customer etc. I have it working using setfocus and date functions however it erases any information already in the field. Is there a way to skip to the end of the field and insert a new line, then add the date and allow me to begin typing?I would like the end result to look like the following.

16/02/2013: Introduced Myself and the company, spoke to joe bloggs and agreed to call back on 28/02/2013.
28/02/2013: returned call to Joe Bloggs but was out of office, will call back 01/03/2013.
01/03/2013: Spoke to Joe Bloggs and have arranged for him to visit us on 10/03/2013.

View 8 Replies View Related

Forms :: How To Insert Data By Clicking Button

Feb 11, 2014

I am new with ms Access. I am using 2013 version and stuck with "pretty" easy task.

When I create the form, the values are inserted/updated constatly as I leave the input components. However I would like to insert/update the record only when I click the button. How to do that?

View 5 Replies View Related

Forms :: Insert Same Date Into Column With Button

Feb 10, 2014

I have form with these info : customer (Table), EnterDate (Button) and customersub (subform), i want to enter date into Date column using form with button.

example

ID name sample date
1. John A ....
2. Michel B ....
3. Jack C .....

into like this

ID name sample date
1. John A 2/2/2014
2. Michel B 2/2/2014
3. Jack C 2/2/2014

I try this this sql. but the date only insert/update for avery row i was select.

Q: How i can make sure i put one date.. it will insert for every row just one click.

Private Sub EnterDate_Click()
CurrentDb.Execute "UPDATE Customer " & _
"SET Date='" & Me.insertdate & "'" & _
"WHERE ID= " & Me.Costumersub.Form.Recordset.Fields("ID")
End Sub

View 2 Replies View Related

INSERT INTO Query

Apr 24, 2006

Hi, with SQL code, I was wondering if/how it is possible to use more than one SELECT statement in an INSERT INTO statement.

So, basically, I want my code to look something like this but I am not sure of the correct syntax:

INSERT INTO tablename
VALUES
(SELECT........), ('value 1)
(SELECT........) ('value 2)

View 1 Replies View Related

INSERT INTO Query

Apr 24, 2006

Hi, with SQL code, I was wondering if/how it is possible to use more than one SELECT statement in an INSERT INTO statement.

So, basically, I want my code to look something like this but I am not sure of the correct syntax:

INSERT INTO tablename
VALUES
(SELECT........), -> value 1
(SELECT........) -> value 2

View 1 Replies View Related

Insert Query

May 8, 2006

hi,

is it possible to have an insert query to fill some of the parameters by select query from other table and rest of the parameters by passing the value.


ex:
insert into table1(a,b,c) values (10,select b fom table2 where.... , 35);

i tried with the above syntax but was unable to succeed.

if this is not possible can anyone help me in solving the problem




thanks,

aravind

View 1 Replies View Related

INSERT INTO Query

Feb 21, 2007

Hi,

I'm trying to write the VBA code to insert data into an audit table. My code is in a function which will have the values to be inserted to it passed to the function.

My function code looks like:

Function InsertAuditRecord(stAction, stTimestamp, stUser) As String

Dim SQL As String

SQL = "INSERT INTO tblAuditLog " & _
"(UpdateDescription, UpdateTimestamp, UpdatedBy) " & _
"VALUES (stAction, stTimestamp, stUser)"

DoCmd.SetWarnings False
DoCmd.RunSQL SQL
DoCmd.SetWarnings True

stAction = ""
stTimestamp = ""
stUser = ""

End Function


The values "stAction", "stTimestamp" and "stUser" are the values passed by the calling procedure, but when this query is executed, the Enter Parameter Value window pops up, asking for the values for each of these 3 variable.

Can anyone tell me how to code the query so that it will use the values passed to the function?

Thanks,
Michael.

View 2 Replies View Related

Forms :: Insert New Data And Show All Records In Subform

Mar 27, 2013

I have a form with a subform. I want to use the main form to insert new data and the subform to show all records that are there. One could say that the after inserting a new record with the fields in the form and save it, it should appear in the subform datasheet view.

Please see attached the sample database..

View 3 Replies View Related

Forms :: Insert Data Into Table By Calculated Files?

Mar 12, 2014

I have calculated files in a form which is summimg the working hrs of each employ�es for a particular data.

I am able to show the same in the form but want to add this value in the table.

Is is possible to add this data from the form to the able?

View 1 Replies View Related

Forms :: Command Button - Insert Into Single Record

Dec 3, 2014

I currently have a command button to run the following...

DoCmd.OpenQuery "Credit Card Report", , acAdd

Which is an appended query.

However, I don't want it to add the whole table each time this is pushed but when trying to use...

DoCmd.RunSQL "INSERT INTO [Credit Cards] ([Provider's Name], [Patient Name], [Patient Account Number] ... VALUES ([Provider's Name.Value], [Patient Account Number.Value], [Patient Account Number.Value]"

It doesn't want to add the single record and gives me an error. I'm pretty sure my syntax is wrong but not sure how to correct it.

The fields I want added are ... Provider's Name , Patient Name, Patient Account Number...

View 1 Replies View Related

Forms :: How To Insert 8 Month In Table By 1 Button Click

Apr 16, 2015

How to insert in my table 8 month by using 1 click like this

row one 1/2/2015
row two 1/3/2015
row three 1/4/2015
.
... row Eight 1/9/2015

View 4 Replies View Related

Forms :: Insert / Select Values From Selection Combo Box

May 20, 2013

I want to insert obtain marks of the subjects. Find the attached my db. when i select combo value my requirement is to insert the all records which associate with the combo. but when i select combo value it will happen nothing.

View 7 Replies View Related

Forms :: Insert Hyperlink Into Form Pointing To File?

Dec 19, 2013

i have a table of calls, with a field called "link to file".

i have a form where staff fill in their calls and when they have completed the call there is an option to insert a hyperlink to where the file is stored.

i previosuly had an attachemnt there but the database would just grow and grow so now its prefered there is a link to where the files are kept.

i just dont know how to set it up, i have tried adding in a text field and setting it to hyperlink which does work but on the form the user has to right click the button and edit hyperlink to place it in - is there an easier way of just clicking the button and it brings up a folder location where you select the file and it saves it as a hyperlink into the table under linked to file?

View 8 Replies View Related







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