473,386 Members | 1,748 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,386 software developers and data experts.

Auto Number Not Linking

80
Ok, I have 3 tables, one with a customer ID(PK) number and info about the customer(customer table). Another table with an order number(PK), with payment info and such, bieng linked by the customer id(FK),(orderinfo table). And a final table with the order number and the description/items that make up the order(order table). I did it this way so i can have more that 1 item per order number.

Heres kinda what it looks like:

Expand|Select|Wrap|Line Numbers
  1. Customer table              Order Info table               Order table  
  2.  
  3.  
  4. |Customer ID*|-------------|Customer ID    |    /--|Order Number|
  5. |Name        |             |Order Number*  |---/   |Item        |
  6. |Phone       |             |Payment Method |       |Quantity    |
  7. |etc...      |             |ect...         |       |etc...      |
  8.  
  9.  
  10. where both *'s are primary keys, and auto numbers
  11.  
I have a form to enter the customer info, and order info, and a subform that handles the order stuff. But I cant make a new order. Everything works, as far as displaying current orders, and I can make new orders if I go into datasheet view of the tables.

Its like the order number(auto number) isnt making a new number.

Any ideas about how to get this working would be greatly appreciated.
Aug 8 '07 #1
26 2171
Stang02GT
1,208 Expert 1GB
Technically, a subform isn't considered an open form, but is a control on the main form, and can't be referenced as this.

You'll have to setfocus to the subform, then perform the acnewrec, and set focus back to the main form again. This is one way to do it. Put this code in the On_Click event of a button. Try it and let me knwo if it works


Expand|Select|Wrap|Line Numbers
  1. Me![sub form name].SetFocus
  2. DoCmd.GoToRecord ,,acnewrec
  3. Me!parentformName.SetFocus
Aug 8 '07 #2
Scotter
80
Ok, I tried the code, but pretty much nothing happens.
Aug 8 '07 #3
mlcampeau
296 Expert 100+
what are the queries that you are basing your forms on?
Aug 8 '07 #4
Scotter
80
Im basing my form on a querry that basically has almost all the fields, accept for a few that im not using in the form.
Aug 8 '07 #5
mlcampeau
296 Expert 100+
Im basing my form on a querry that basically has almost all the fields, accept for a few that im not using in the form.
can you post the sql?
Aug 8 '07 #6
Scotter
80
The querys sql is;

Expand|Select|Wrap|Line Numbers
  1. SELECT CUST_NAME.[Customer ID Number], CUST_NAME.[First Name], CUST_NAME.[Last Name], CUST_NAME.Phone, CUST_NAME.Address, CUST_NAME.City, CUST_NAME.State, CUST_NAME.Zip, ORDERS.[Order Number], ORDERS.[Payment Method], ORDERS.Deposit, ORDERS.Due, ORDERS.[Delivery Date], ORDERS.[Pick up Date], Items.Item, Items.[Tent Size], Items.Combo, Items.[Table Cloth], Items.[# of Tables], Items.[# of Chairs], Items.[# of Table Cloths], Items.[Order Number]
  2. FROM (CUST_NAME INNER JOIN ORDERS ON CUST_NAME.[Customer ID Number] = ORDERS.[Customer ID Number]) INNER JOIN Items ON ORDERS.[Order Number] = Items.[Order Number];
  3.  
Aug 8 '07 #7
mlcampeau
296 Expert 100+
The querys sql is;

Expand|Select|Wrap|Line Numbers
  1. SELECT CUST_NAME.[Customer ID Number], CUST_NAME.[First Name], CUST_NAME.[Last Name], CUST_NAME.Phone, CUST_NAME.Address, CUST_NAME.City, CUST_NAME.State, CUST_NAME.Zip, ORDERS.[Order Number], ORDERS.[Payment Method], ORDERS.Deposit, ORDERS.Due, ORDERS.[Delivery Date], ORDERS.[Pick up Date], Items.Item, Items.[Tent Size], Items.Combo, Items.[Table Cloth], Items.[# of Tables], Items.[# of Chairs], Items.[# of Table Cloths], Items.[Order Number]
  2. FROM (CUST_NAME INNER JOIN ORDERS ON CUST_NAME.[Customer ID Number] = ORDERS.[Customer ID Number]) INNER JOIN Items ON ORDERS.[Order Number] = Items.[Order Number];
  3.  
Are you using this same query for both your main form and your subform??
Aug 8 '07 #8
Scotter
80
no, the record source for the subform is based on the fields in the subform
Aug 8 '07 #9
mlcampeau
296 Expert 100+
no, the record source for the subform is based on the fields in the subform
I'm sorry, you've confused me a bit here. So the above query is what you've based your main form on? What is the sql for the query you based your subform on?
Aug 8 '07 #10
Scotter
80
SELECT DISTINCTROW [Items].[Order Number], [Items].[Item], [Items].[Tent Size], [Items].[Combo], [Items].[Table Cloth], [Items].[# of Tables], [Items].[# of Chairs], [Items].[# of Table Cloths] FROM [Items];
Aug 8 '07 #11
Scotter
80
SELECT DISTINCTROW [Items].[Order Number], [Items].[Item], [Items].[Tent Size], [Items].[Combo], [Items].[Table Cloth], [Items].[# of Tables], [Items].[# of Chairs], [Items].[# of Table Cloths] FROM [Items];
But its not a saved query, its just typed in the record source. If that matters for anything.
Aug 8 '07 #12
mlcampeau
296 Expert 100+
SELECT DISTINCTROW [Items].[Order Number], [Items].[Item], [Items].[Tent Size], [Items].[Combo], [Items].[Table Cloth], [Items].[# of Tables], [Items].[# of Chairs], [Items].[# of Table Cloths] FROM [Items];
First off, have you linked your subform and main form?
Secondly, I'm not exactly sure, but I'm wondering if your problem has something to do with the fact that your query for your subform is just a part of your query for your main form.
Is there a particular reason that you are selecting [Items].[Order Number], [Items].[Item], [Items].[Tent Size], [Items].[Combo], [Items].[Table Cloth], [Items].[# of Tables], [Items].[# of Chairs], [Items].[# of Table Cloths]
in your main form query? If not, try removing the Items table fields from your main form query, and then link your subform and main form by OrderNumber.
Aug 8 '07 #13
mlcampeau
296 Expert 100+
But its not a saved query, its just typed in the record source. If that matters for anything.
Try saving the query and then changing the record source to the name of the query. I don't know if it will make a difference, but it very well might
Aug 8 '07 #14
Scotter
80
ok I tried removing thoose fields from the query, but doesnt work. After I remove them the sub form and everything gets messed up, and the subform doesnt work. When I try to add a new record the error it gives me is

"Can't add record(s); join key of table 'order info' not in recordset."

when I add an order, im putting in the order number, and what they order, all goes into the order table. but its like the order number in the order info table isnt creating a new record when i try to enter payment information and stuff.

That was kinda confusing i know. Sorry:)
Aug 8 '07 #15
Scotter
80
I forgot, but yes my forms are linked by order number, and i added thoose fields to the query because at first I wasnt going to use a subform because I dont enjoy them, but they decided it was necessary because I can see all the items under a certian order that way... If you have any other ideas about how to do this, that would be sweeeeet.
Aug 8 '07 #16
mlcampeau
296 Expert 100+
ok I tried removing thoose fields from the query, but doesnt work. After I remove them the sub form and everything gets messed up, and the subform doesnt work. When I try to add a new record the error it gives me is

"Can't add record(s); join key of table 'order info' not in recordset."

when I add an order, im putting in the order number, and what they order, all goes into the order table. but its like the order number in the order info table isnt creating a new record when i try to enter payment information and stuff.

That was kinda confusing i know. Sorry:)
Okay, yes that was confusing but I'll try to work with it. I'm pretty sure I understand what your problem is. So, you enter the order number and order info in the subform, but you try to enter the payment info and such in the main form, but the main form doesn't get updated with the order number from the subform. Is that right?
I am just noticing that in your queries you are referring to a CUST_NAME table, Items table, and Orders table. In your first post you mentioned a customer table, Order Info table, Order table. Are these actually the same tables? I'm going to assume they are.
You didn't answer if you have the main form and subform linked. If so, are they just linked by the Order Number?
Aug 8 '07 #17
mlcampeau
296 Expert 100+
I forgot, but yes my forms are linked by order number, and i added thoose fields to the query because at first I wasnt going to use a subform because I dont enjoy them, but they decided it was necessary because I can see all the items under a certian order that way... If you have any other ideas about how to do this, that would be sweeeeet.
On your subform do you allow more than one Order Number to be entered? I'm just wondering if it would be easier to enter the order number on the main form, and then link the two forms by order number....Bare with me. I'm still kind of new at Access and am self-teaching.
Aug 8 '07 #18
Scotter
80
Yeah thats how I'm doing it, im puttin in a order number and filtering the results by that order number.

Yeah the non-updating was the problem. But I have to say I pretty much redid the form, and the querries, like you said to, and It looks like everything is going to work, almost. Now I can update everything (score!) but my only issue now is getting the order number to automatically fill in, within the subform(because if your entering a new order, you wont know what number should be there). But I'm seeing the light at the end of the tunnel. Im right with ya on that whole self teaching thing...
Aug 8 '07 #19
mlcampeau
296 Expert 100+
Yeah thats how I'm doing it, im puttin in a order number and filtering the results by that order number.

Yeah the non-updating was the problem. But I have to say I pretty much redid the form, and the querries, like you said to, and It looks like everything is going to work, almost. Now I can update everything (score!) but my only issue now is getting the order number to automatically fill in, within the subform(because if your entering a new order, you wont know what number should be there). But I'm seeing the light at the end of the tunnel. Im right with ya on that whole self teaching thing...
Well, I'm glad it's looking promising. On which form are you trying to get the order number to automatically fill in?
Aug 8 '07 #20
Scotter
80
Everything is finally working correctly. I'm going to attempt to explain what I had to fix...

I had to redo the query and take out all the fields that were on the subform and only leave the fields that were on the main form(plus the order number). I had to make another query with the fields that i wanted in the subform. Then I had to change the record source for the subform to the new query, and re-do the link betweek the tables. and thats about it...

So now I just need to make a button that makes a new record, instead of using the nav bar on the bottom.
Aug 8 '07 #21
mlcampeau
296 Expert 100+
Everything is finally working correctly. I'm going to attempt to explain what I had to fix...

I had to redo the query and take out all the fields that were on the subform and only leave the fields that were on the main form(plus the order number). I had to make another query with the fields that i wanted in the subform. Then I had to change the record source for the subform to the new query, and re-do the link betweek the tables. and thats about it...

So now I just need to make a button that makes a new record, instead of using the nav bar on the bottom.
I'm glad you got it to work! As for the button, that will require some VBA coding and that is definitely NOT a specialty of mine (not like anything in Access is...)! Good luck with it though!
Aug 8 '07 #22
FishVal
2,653 Expert 2GB
The querys sql is;

Expand|Select|Wrap|Line Numbers
  1. SELECT CUST_NAME.[Customer ID Number], CUST_NAME.[First Name], CUST_NAME.[Last Name], CUST_NAME.Phone, CUST_NAME.Address, CUST_NAME.City, CUST_NAME.State, CUST_NAME.Zip, ORDERS.[Order Number], ORDERS.[Payment Method], ORDERS.Deposit, ORDERS.Due, ORDERS.[Delivery Date], ORDERS.[Pick up Date], Items.Item, Items.[Tent Size], Items.Combo, Items.[Table Cloth], Items.[# of Tables], Items.[# of Chairs], Items.[# of Table Cloths], Items.[Order Number]
  2. FROM (CUST_NAME INNER JOIN ORDERS ON CUST_NAME.[Customer ID Number] = ORDERS.[Customer ID Number]) INNER JOIN Items ON ORDERS.[Order Number] = Items.[Order Number];
  3.  
Hi, Scotter.

What is the reason to join all three tables and set it as a RecordSet of the main form where only first two are supposed to be modified?
Aug 8 '07 #23
mlcampeau
296 Expert 100+
Hi, Scotter.

What is the reason to join all three tables and set it as a RecordSet of the main form where only first two are supposed to be modified?
Hi FishVal. If you refer to post 21, Scotter mentioned that he took the unnecessary fields out of the query that you are questioning. Post 16 explains that he had them in there from when he tried to design the form without using a subform.
Aug 8 '07 #24
Scotter
80
yea, once i removed thoose fields from the query, and redid some of the form everything is working now.
Aug 8 '07 #25
Stang02GT
1,208 Expert 1GB
Sorry Scotter I got tied up in meetings for the rest of the day and was unable to get back to you. But its good to see that you were able to get your problem solved.
Aug 8 '07 #26
Scotter
80
no problem, mlcampeau had my back, but I'm sure ill need more help soon.
Aug 8 '07 #27

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

Similar topics

1
by: Ken | last post by:
Need help on the Auto Number or Identity Seed on the Oracle Database I got an Access database that need to be converted to Oracle 9i. Somehow the Trigger we created to simulate the "AUTO NUMBER"...
2
by: Tom | last post by:
I am trying to store information into a table that has an auto increment field. There is currently no data in the table. Using the code below I cannot insert data into the table. I get an error...
5
by: Geoff Cayzer | last post by:
At http://www.blueclaw-db.com/tips_tricks.htm I came across a section which is included below and was hoping for some comment on the article. -------------- Almost never use this auto-number...
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...
6
by: Sebastien | last post by:
Hi, I am building a products database, linking sales and production. Each part has a unique sales Stock Code and Production Number. The sales stock code is a combination of letters and numbers...
2
by: Mike N. | last post by:
Hello- I have a database that uses an auto number field type that goes out of sync periodically. My customer gets a "cannot add record, number already in use" error message. I dump the records...
4
by: Shahar | last post by:
Hi I need to get a field name 'ID'(that is an auto-number field) right after I add a new row to table, it's work like that: myCommand.ExecuteNonQuery(); myCommand.CommandText = "SELECT...
13
by: S.Dickson | last post by:
I had an access database that i use as an ordering system. I have a form for entering customer details. When i add a new customer on the form the customer number is an auto number that appears when...
5
by: David Wright | last post by:
Hello Everyone I would be grateful if someone could help me with the automatic increment of a field on my subform called ‘Test_SrNo’. I am Using Microsoft Office 2000. The auto entry of the...
0
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,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
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...
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
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...
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
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...

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.