473,657 Members | 3,041 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Updating table values through a form from another table.

I'm trying to do an automatic update of one table from another through a
form. Basically, when a selection is made for an item, in this case a
particular workshop, I want to get the associated price of that workshop
from the Workshop table and update my ScheduleDetails table. The tables are
as follows:

tblStudent
StudentID
LastName
FirstName
....etc...

tblScheduleDeta ils
ID
StudentID
WorkshopID
UnitPrice

tblWorshop
WorkshopID
Name
Date
Time
Location
Instructor
Price

So I'm using an After Update VBA event procedure titled
WorkshopID_Afte rUpdate() value that reads:

Me![UnitPrice] = Me![WorkshopID].Column(6)

When I select a workshop (by selecting the ID from a subform) the value that
is in the UnitPrice column dissapears so I'm wondering how to reference or
specify tblWorkshop at the VBA level. The after update mechanism is working
just fine but the price is not getting from tblWorkshop to
tblScheduleDeta ils.

Any help is appreciated, I've been using VBA for about 3 days now so I'm
even a little fuzzy on what "Me" does for me...

Chuck
Nov 13 '05 #1
6 6162
"cyoung311" <cy*******@cox. net> wrote in message
news:JehLc.1295 8$Wv4.9561@okep read03
I'm trying to do an automatic update of one table from another
through a form. Basically, when a selection is made for an item, in
this case a particular workshop, I want to get the associated price
of that workshop from the Workshop table and update my
ScheduleDetails table. The tables are as follows:

tblStudent
StudentID
LastName
FirstName
...etc...

tblScheduleDeta ils
ID
StudentID
WorkshopID
UnitPrice

tblWorshop
WorkshopID
Name
Date
Time
Location
Instructor
Price

So I'm using an After Update VBA event procedure titled
WorkshopID_Afte rUpdate() value that reads:

Me![UnitPrice] = Me![WorkshopID].Column(6)

When I select a workshop (by selecting the ID from a subform) the
value that is in the UnitPrice column dissapears so I'm wondering how
to reference or specify tblWorkshop at the VBA level. The after
update mechanism is working just fine but the price is not getting
from tblWorkshop to tblScheduleDeta ils.

Any help is appreciated, I've been using VBA for about 3 days now so
I'm even a little fuzzy on what "Me" does for me...

Chuck


"Me" is just a shorthand reference to the current form (ie.
Me![UnitPrice] is the same as Forms![frmMyFormName]![UnitPrice])

You may be referencing the wrong column from your combo box. In VBA the
column numbering starts at zero. Therefore, the 6th column is referenced
by the statement....

Me![WorkshopID].Column(5)
--
regards,

Bradley
Nov 13 '05 #2
C Y

Thanks Bradley. The item that is the source is "Price" from tblWorkshop
and is the 0,1,2,3,4,5,6th element of each record. I want this value to
go to tblScheduleDeta ils "UnitPrice" field. So price is the 7th field
(Column(6)) but I'm wondering if I might need to link that table to the
form? Right now the master and child references both contain StudentID
which is contained in both tblStudent and tblScheduleDeta ils. I need to
get to tblWorkshop which would be pointed to by WorkshopID. Can there
be more than one entry in the master and child fields?
Like separated by ";"s?

Best regards,

Chuck
*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!
Nov 13 '05 #3
Yes, the LinkMasterField s and LinkChildFields can contain multiple fields,
and the combination of fields will be used to synchronize the main form and
the form embedded in the subform control. From what I scanned quickly here,
it does not seem that the StudentID would enter into accessing tblWorkshop
to get the price, so I don't see how that would apply.

When you are referring to the control [WorkshopID], is that a ComboBox? If
so, the RowSource would identify the table from which you are selecting
data, and there would be no need for the ID to be in the LinkMasterField s
and LinkChildFields (because their only use is to synchronize data in the
main and sub forms). And, of course, your RowSource must include all the
Fields you need... but it can be a Query that only references, say,
WorkshopID, WorkshopName, and Price. I strongly recommend that you do not
use Name or Date for Field names -- they are Access reserved words and can
cause you all kinds of unobvious problems.

(If you did only use the three Fields in the RowSource Query, then Price
would be (2), not (6) -- it refers to the Column property of the Combo,
determined by what you use as RowSource, not to the underlying table
itself.)

One thing that might be causing you a problem is if, as it appears to me you
may be, you are using the same name for the Control as for the Field that is
the Control Source. Yes, the Access wizards do this, but it can be
confusing... so many of us use some naming convention (the one I used is
called the Reddick Naming Convention... you can Google on that, or search at
http://support.microsoft.com for details) that appends an identifying
prefix, e.g., "cbo" for Combo, and avoids possible confusion. Try renaming
your combo to cboWorkshopID and your and see if that helps.

Larry Linson
Microsoft Access MVP

"C Y" <cy*******@cox. net> wrote in message
news:40******** **************@ news.newsgroups .ws...

Thanks Bradley. The item that is the source is "Price" from tblWorkshop
and is the 0,1,2,3,4,5,6th element of each record. I want this value to
go to tblScheduleDeta ils "UnitPrice" field. So price is the 7th field
(Column(6)) but I'm wondering if I might need to link that table to the
form? Right now the master and child references both contain StudentID
which is contained in both tblStudent and tblScheduleDeta ils. I need to
get to tblWorkshop which would be pointed to by WorkshopID. Can there
be more than one entry in the master and child fields?
Like separated by ";"s?

Best regards,

Chuck
*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!

Nov 13 '05 #4
Larry,

Thanks for your response. I'm learning as we go here but I did try the
link master and child fields by adding WorkshoID and it didn't like it.
It appears that the form doesn't know anything about tblWorkshop, just
tblStudent and tblScheduleDeta ils.

The combo that I am using is based on tblScheduleDeta il and not on a
query or the subform itself. tblScheduleDeta il references tblWorkshop
to get the text name of the workshop (2nd field of table) so I'm
guessing that what you have said is that the VBA code will only
recognize one field by WorkshopID (a single column?). Perhaps I should
use a query to get to the Workshop data instead of going directly to the
table from the form???

Best regards,

Chuck
Nullum Gratuitum Prandium
*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!
Nov 13 '05 #5
"Chuck" <an*******@cox. net> wrote
Thanks for your response. I'm learning as we
go here but I did try the link master and child
fields by adding WorkshoID and it didn't like it.
Well, of course not... WorkshopID does not enter into synchronizing the
records between the main form and the subform.
It appears that the form doesn't know anything
about tblWorkshop, just tblStudent and
tblScheduleDeta ils.
Did you expect it to _infer_ something because of the WorkshopID field in
tblScheduleDeta ils? See below...
The combo that I am using is based
on tblScheduleDeta il and not on a
query or the subform itself. tblScheduleDeta il
references tblWorkshop to get the text name
of the workshop (2nd field of table) so I'm
guessing that what you have said is that the
VBA code will only recognize one field by
WorkshopID (a single column?). Perhaps I
should use a query to get to the Workshop
data instead of going directly to the
table from the form???


From your description, you have a Lookup Field for Workshop in the
tblScheduleDeta il. I consider Lookup Fields one of the worst "enhancemen ts"
Microsoft has ever made to Access -- they are very nice for the end-user who
only looks at tables in datasheet view. In every other case, as in yours, it
obscures what is there. Your tblScheduleDeta ils actually contains the ID,
but it shows you the name... and it does not retrieve the other fields from
tblWorkshop.

Proper table design would include the ID field of the appropriate workshop
as a "foreign key" and you'd retrieve the other Workshop data via a Query
that joined the two tables on the corresponding fields.

Unfortunately, I just don't seem to have enough information about what you
are doing to understand how you expect to get the Price from Workshop ID
from a ComboBox with a RowSource of tblScheduleDeta ils. Isn't it the
tblScheduleDeta ils "Price" field that you want to set? Is the
tblScheduleDeta ils the RecordSource of the Form embedded in the Subform
Control? Why would the ComboBox in the Subform not refer to tblWorkshop to
get a Price? Further, why would a Combo Box in a Form whose RecordSource was
tblScheduleDeta ils have a RowSource of the same tblScheduleDeta ils?

Larry Linson
Microsoft Access MVP


Nov 13 '05 #6
Larry,

The Combo box has a rowsource of tblWorkshop. I modded that RowSource
query to retrieve the WorkshopID, WorkshopName and also Price. It is
this Price that I'm trying to load into the tblScheduleDeta ils UnitPrice
field.

Since adding the "Price" field to the query I've modified the VBA event
procedure code to now:

Me![UnitPrice] = Me![WorkshopID].Column(2)

and now I get a message box with "Runtime error 438; Object doesn't
support this property or method".

Thanks again for your assistance,

Chuck
Nullum Gratuitum Prandium
*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!
Nov 13 '05 #7

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

Similar topics

3
2496
by: steve | last post by:
Hello, I am trying to take all the data from one table and transfer it to another table with exactly the same column names in the same database. I have done this with a small sql script in an update query but now can't seem to figure out how. =( I am doing this because one of the tables is a linked table to a mysql table and I am copying the data then deleting the original table which is in access 2000. Thanks for any help steve
3
2462
by: bitoulis | last post by:
Hi, is it possible to use the records of a table as the field names of another table? If yes, how is it done? Thanks in advance Laertes
0
257
by: Leonardo Gangemi | last post by:
How to align right a table based on another table created dinamically? Leonardo
2
2294
by: S0ck3t | last post by:
Please could I have some help on matching records between tables. I want to return a check (true/false) stating whether the field combination in table 1 occurs in table 2. Obviously it's easy with just one field, but two is more problematic. I have the following Table1 -------- field1
1
5213
by: Jan | last post by:
I have a table with autoincrement unique ID plus name (required not to be blank) and other fields. I have a list of names in another table and would like to do insert to the name field of the other table. How do I do it? I get error messages when trying different approaches. In the end, I removed the unique key/autoincrement, inserted and ID field in the source and then did copy&append records in the edit menu and changed it all back....
4
1607
by: Cyberwolf | last post by:
I have a form that users enter information into. What I want to do is to update certain fields from another table once they have entered a number in a field. The form is already based on a query as this allows the user to see only the records they entered. What would be the best approach to this? TIA, Cyberwolf
3
8439
by: Will1234321 | last post by:
Hello, This is my first post. I will try to be as descriptive as possbile. Please let me know if you need more info to help me out. I am using Access 2000 and Windows 98. I am creating a form to enter data into a table. The form is called frmNewLot and the table is called tblLots. The other table in question is tblLotors. The tables are related through a LotorID field. There are address fields (address1, address 2, city, state, zip) in...
1
1692
by: lunas | last post by:
hi i have to update a table based on a criteria with value selected from another table. i am writting a java progg for it . i just want to know can it be done with one statement. my purpose is result set rs =select (ID) from Tab1 where colmB is null LOOP rs select ID2 from tab2 where colC=ID
1
2174
by: zoeb | last post by:
Currently I have a table, and would like the calculate a field in the table by referencing values from another 3 tables. i.e. tblData Index1, Index2, Index3, Value 1 2 3 2 2 2 1 3 4 and tblIndex1 Value Data 1 2.5
1
2308
by: JoeKid09 | last post by:
Hi Guys, Thanks in advance for your help. I unpivoted a table which I want to insert into another table. Below is my script. I got an error; anyone can see where my error is. insert into MASTER_FINANCIALS ( , , ,FINANCIAL_DESC ,FINANCIAL_VALUES
0
8302
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
8718
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
8499
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
7314
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
6162
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
4300
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
2726
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
1937
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
2
1601
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.