472,371 Members | 1,632 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

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

Help - Updateable query adds new row with missing criteria fields

JM
Hello,

I've created a Querydef in a Form_Load() sub. The form is a subform
that no longer has linked child fields. The form is bound to this
querydef. When I open the form, the fields are populated just fine.
However, when I add a new record using the new record control at the
bottom of the subform, it gets added with NULL for the two values that
were in the original WHERE clause.

For example, if my query was "SELECT batch, style, serial_no,
warehouse, color from chair_inventory WHERE batch = 138 and style = 6",
the form is populated. Then, when I add a new record, it gets added
with the serial_no, warehouse, and color I specified, but batch and
style are NULL. How can I make the dynaset pick up the original
criteria and insert them?

Thanks,

JM

Nov 13 '05 #1
2 1650
you'll need to capture the criteria and programmatically insert it into the
proper fields in the new record. you can do this on the subform's Insert
event, or BeforeUpdate event, by just setting the value of the fields in
VBA. something like

Me!BatchField = thebatchcriteria
Me!StyleField = the stylecriteria

how you capture the criteria depends on how you fed them to the query in the
first place. if you entered the criteria in controls on another form that
remains open, you can refer to those controls in the code directly, as
Forms!MyCriteriaForm!MyBatchCriteriaControl

if you generated the criteria request in the subform's Load event, it should
be simple enough to save the return values into variables, so they're
available while the subform remains open.

hth
"JM" <jm***********@yahoo.com> wrote in message
news:11**********************@g49g2000cwa.googlegr oups.com...
Hello,

I've created a Querydef in a Form_Load() sub. The form is a subform
that no longer has linked child fields. The form is bound to this
querydef. When I open the form, the fields are populated just fine.
However, when I add a new record using the new record control at the
bottom of the subform, it gets added with NULL for the two values that
were in the original WHERE clause.

For example, if my query was "SELECT batch, style, serial_no,
warehouse, color from chair_inventory WHERE batch = 138 and style = 6",
the form is populated. Then, when I add a new record, it gets added
with the serial_no, warehouse, and color I specified, but batch and
style are NULL. How can I make the dynaset pick up the original
criteria and insert them?

Thanks,

JM

Nov 13 '05 #2
JM


tina wrote:
you'll need to capture the criteria and programmatically insert it into the
proper fields in the new record. you can do this on the subform's Insert
event, or BeforeUpdate event, by just setting the value of the fields in
VBA. something like

Me!BatchField = thebatchcriteria
Me!StyleField = the stylecriteria

how you capture the criteria depends on how you fed them to the query in the
first place. if you entered the criteria in controls on another form that
remains open, you can refer to those controls in the code directly, as
Forms!MyCriteriaForm!MyBatchCriteriaControl

if you generated the criteria request in the subform's Load event, it should
be simple enough to save the return values into variables, so they're
available while the subform remains open.

hth


Tina,

Thanks very much for the suggestion. I'll try it. I neglected to
mention that the table is SQL Server 2000 linked ODBC. When the table
was Access, the application worked as designed. I know the linked
table broke the Dynaset insert, and I wish I knew why. I hate when I
get asked to put a SQL Server back end on an Access front-end. Thanks
again.

Nov 13 '05 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

5
by: Marie | last post by:
Access97 I have a table containing addresses with a separate field for State. Is there a way to create a query that returns an unique list of the states in that table and still be updateable? I...
5
by: Norma | last post by:
I am trying to make a query pull data from between the dates I enter in the parameter but also look back 'in time' to see where 2 other fields have null values, and only pull data into the query if...
4
by: Laura | last post by:
Here's the situation: I'm trying to use an update query to copy data from one row to another. Here is the situation: I have 5 companies that are linked to each other. I need to show all 5...
1
by: James | last post by:
Access 2003, trying to count the number of records that meet a criteria. According to Help: "In the Database window, click Queries under Objects, and then click New on the database window...
1
by: Ivan Carey | last post by:
How can a query display multiple fields with diferent condition on the same field example I have a field name of reason and a field name of duration. I would like to display 2 fileds of total...
10
by: motessa | last post by:
Hello All, I am new to Access and have been looking for answers to my problem on the internet and have not found it yet. I hope someone can give me a hint. Thanks so much. I have a form...
1
by: melody.charlesworth | last post by:
I link fields in tables 1 and 2 (one to one or unmatched) in order to update fields in table 2 with others from table one. If I use criteria from one of these tables there is no problem but if I...
47
by: Jo | last post by:
Hi there, I'm Jo and it's the first time I've posted here. I'm in process of creating a database at work and have come a little unstuck.....I'm a bit of a novice and wondered if anyone could...
1
by: RussCRM | last post by:
I need some help getting unique records from our database! I work for a small non-profit homeless shelter. We keep track of guest information as well as what services we have offered for...
2
by: Kemmylinns12 | last post by:
Blockchain technology has emerged as a transformative force in the business world, offering unprecedented opportunities for innovation and efficiency. While initially associated with cryptocurrencies...
0
by: Naresh1 | last post by:
What is WebLogic Admin Training? WebLogic Admin Training is a specialized program designed to equip individuals with the skills and knowledge required to effectively administer and manage Oracle...
0
by: Arjunsri | last post by:
I have a Redshift database that I need to use as an import data source. I have configured the DSN connection using the server, port, database, and credentials and received a successful connection...
0
Oralloy
by: Oralloy | last post by:
Hello Folks, I am trying to hook up a CPU which I designed using SystemC to I/O pins on an FPGA. My problem (spelled failure) is with the synthesis of my design into a bitstream, not the C++...
0
by: Carina712 | last post by:
Setting background colors for Excel documents can help to improve the visual appeal of the document and make it easier to read and understand. Background colors can be used to highlight important...
0
by: Rahul1995seven | last post by:
Introduction: In the realm of programming languages, Python has emerged as a powerhouse. With its simplicity, versatility, and robustness, Python has gained popularity among beginners and experts...
2
by: Ricardo de Mila | last post by:
Dear people, good afternoon... I have a form in msAccess with lots of controls and a specific routine must be triggered if the mouse_down event happens in any control. Than I need to discover what...
1
by: Johno34 | last post by:
I have this click event on my form. It speaks to a Datasheet Subform Private Sub Command260_Click() Dim r As DAO.Recordset Set r = Form_frmABCD.Form.RecordsetClone r.MoveFirst Do If...
1
by: ezappsrUS | last post by:
Hi, I wonder if someone knows where I am going wrong below. I have a continuous form and two labels where only one would be visible depending on the checkbox being checked or not. Below is the...

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.