473,396 Members | 2,013 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

MS Access Append Record

2
Hi all,

I have a problem with a query in access that I cant seem to figure out. I have a form named frmRecruitment with a subform named sfrmParticipant. At the moment I am using an append query to append records from 'sfrmParticipant' to 'frmIntervention' using a button on a main form 'frmRecruitment'.

This append query appends all the records from
'sfrmParticipant' to 'frmIntervention' but I only want to append the record that is displayed as the current record in the form or the last record from tblParticipant into tblIntervention and by using the button on the form append only that very last record.

This is what I have so far:
Expand|Select|Wrap|Line Numbers
  1. Private Sub Command31_Click()
  2. DoCmd.RunSQL "INSERT into [tblIntervention]([participantID]) VALUES (participantID)"
  3. End Sub
  4.  
  5. Private Sub Command31_Click() DoCmd.RunSQL "INSERT into [tblIntervention]([participantID]) VALUES (participantID)" End Sub
and yes it appends only the information being displayed or the very last record from tblParticipant into tblIntervention but it prompts me to enter the participantID in order to do it.

How do I modify the append query to only append the form record with out promting me and having to enter the participant ID manually?


Thanks for your help!
hikosj
Jun 6 '08 #1
3 3120
Stewart Ross
2,545 Expert Mod 2GB
Hi. Problem is that you are referring to participantID in the VALUES part of the string. If it is a local variable you will need to append its value to the string instead of including its name:

Expand|Select|Wrap|Line Numbers
  1. DoCmd.RunSQL "INSERT into [tblIntervention]([participantID]) VALUES ("  & participantID & ")"
If participantID is a control on your form rather than a local variable you will need to use the me!participantID syntax to refer to it. Either way, you cannot include its name in the string as the RunSQL command will not be able to interpret what it means - hence why it is asking you for a parameter value.

if participantID is a field from another table (and not a control on your form or a local variable) you will need to obtain its value by using DLookup or somesuch, as again its value will not be available to runSQL simply by referring to its name the way you are doing at present.

-Stewart
Jun 10 '08 #2
NeoPa
32,556 Expert Mod 16PB
Please remember ALWAYS to use [ CODE ] tags whenever posting code on this site.
Jun 12 '08 #3
hikosj
2
Hi. Problem is that you are referring to participantID in the VALUES part of the string. If it is a local variable you will need to append its value to the string instead of including its name:

Expand|Select|Wrap|Line Numbers
  1. DoCmd.RunSQL "INSERT into [tblIntervention]([participantID]) VALUES ("  & participantID & ")"
If participantID is a control on your form rather than a local variable you will need to use the me!participantID syntax to refer to it. Either way, you cannot include its name in the string as the RunSQL command will not be able to interpret what it means - hence why it is asking you for a parameter value.

if participantID is a field from another table (and not a control on your form or a local variable) you will need to obtain its value by using DLookup or somesuch, as again its value will not be available to runSQL simply by referring to its name the way you are doing at present.

-Stewart
I finally figured it out! It took me a while but I finally got it to work.
> I added this to the click event of a button
>
>
Expand|Select|Wrap|Line Numbers
  1.  Dim str As String
  2. > str = Form_frmPresentation.presentationID.Value
  3. > DoCmd.Close
  4. > DoCmd.OpenForm "sfrmAppointmentOne", acNormal, , , , acWindowNormal,
  5. > "Value=" + str
  6. >
  7. >
  8. > 'And then I added this to the on load event of the form getting the variable
  9. >
  10. > Form_frmIntervention.participantID.Value =
  11. > Form_frmParticipant.participantID.Value
  12. > Me.Refresh
Jun 19 '08 #4

Sign in to post your reply or Sign up for a free account.

Similar topics

4
by: JMCN | last post by:
is it possible to insert a value into a field when you append the new records to the table instead of appending the one new record at a time in order to insert a new value? for example, i would...
1
by: Charles | last post by:
Hi MS Access & MS SQL Server Gurus ! I am trying to delete duplicate data from a LINKED SQL Server 2000 table (LinkedTable) and insert the result into a local (in Access) table. The following...
16
by: John Baker | last post by:
Hi: I know this is a strange question, but I have inherited a system where files are copied and records re auto numbered (as an index field) )frequently, and I am wondering how high the number...
8
by: doomx | last post by:
I'm using SQL scripts to create and alter tables in my DB I want to know if it's possible to fill the description(like in the Create table UI) using these scripts. EX: CREATE TABLE(...
2
by: Bubb | last post by:
I have an Access database with one table that I use for stuff I sell online. Each record has the following fields: Unique Id, Cost, and Item Description. I just obtained some more stuff with its...
2
by: Frav | last post by:
The Reps team have been experiencing that Access 2002 unexpectedly quits while working and also lots of Corruption Failures and "Record lock can not update" messages since the upgrade from...
5
by: technocraze | last post by:
Hi guys, i tried using the AddRecord command (Record operation - Add New Record) provided by MS Acess but the new record is not been appended to the table but instead it has been overwritten. ...
4
by: etuncer | last post by:
Hello All, I have Access 2003, and am trying to build a database for my small company. I want to be able to create a word document based on the data entered through a form. the real question is...
3
by: bazdaa | last post by:
Access 2K3 Append/Update ignore non null cells! Hi, I have been tasked with completing an audit of approximately 10,000 items, to which I have generated a list of 40 questions (fields) for...
0
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...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
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,...
0
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...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
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...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.