Wrox Programmer Forums
|
Access Discussion of Microsoft Access database design and programming. See also the forums for Access ASP and Access VBA.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Access section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old January 25th, 2007, 07:33 PM
Friend of Wrox
 
Join Date: Jan 2007
Posts: 109
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via AIM to scandalous Send a message via MSN to scandalous
Default 2 procedures?

I am having trouble trying to making two AfterUpdate procudures.

Basically I am referencing a combobox selection to populate 2 other fields. I can get the first box to populate but the second is doing nothing.

is there a general rule of thumb to creating multiple procedures for one event?
 
Old January 26th, 2007, 08:24 AM
Friend of Wrox
 
Join Date: Mar 2004
Posts: 3,069
Thanks: 0
Thanked 10 Times in 10 Posts
Default

Just put the code in the same Sub.

Also, for this kind of update, put the code in the BEFORE Update event. If you need to capture these changes on a new record, duplicate the code in the BEFORE Insert event as well.

Did that help? If not, post the code you are using, including Sub headings.

mmcdonal
 
Old January 26th, 2007, 10:08 AM
Friend of Wrox
 
Join Date: Jan 2007
Posts: 109
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via AIM to scandalous Send a message via MSN to scandalous
Default

K i tried that and the second field still isnt populating. I have four fields i am using on a form. ("ManufacturerID", "PartNumber", "Descritpion", "Price") What I am trying to do is use make sure that after the user selects the MFGID that the Part list is limited to those parts by that manufacturer. When a part# is selected the description and Price populate (Codeset2). Maybe I am making this complicated and there's an easier way?

Code set 1:
Private Sub MFGID_Afterupdate()

strSearch = "[MFGID] =" & Chr$(34) & Me![PartNumber] & (34)
me ! [PartNumber].requery
End Sub

Code set 2:

Private Sub PartNumber_Afterupdate()

  'autopop the default price in the hidden 2nd column
  Me.Price = Me.PartNumber.Column(1)
  'autopop the default desciption in the hidden 3rd column
  Me.Description = Me.PartNumber.Column(2)
End Sub

Maybe these boxes need to be unbound? Sorry I am probably making significant mistakes but I have been only doing this for about 3 weeks.

 
Old January 26th, 2007, 10:41 AM
Friend of Wrox
 
Join Date: Mar 2004
Posts: 3,069
Thanks: 0
Thanked 10 Times in 10 Posts
Default

Change this:

strSearch = "[MFGID] =" & Chr$(34) & Me![PartNumber] & (34)

To this:

Dim sPart As String

sPart = Me.PartNumber

strSearch = "[MFGID] = '" & sPart & "'"

Chr$(34) should be Chr(34) at least, but ANSI 89 wants ', not " here.

Is this where the problem is?

I am not sure what you are doing with this first part of the code since strSearch is not acting on the partnumber combo box.

Bound text boxes should work fine here. Are you working on a form and subform, or just a form?

If just a form, then just move the code to the Before Update and Before Insert events, but take the values to variables first:

Dim cPrice As Currency
Dim sDesc As String

cPrice = Me.PartNumber.Column(1)
sDesc = Me.PartNumber.Column(2)

Me.Price = cPrice
Me.Description = sDesc

Pay attention to the event this code is on.






mmcdonal
 
Old January 26th, 2007, 05:04 PM
Friend of Wrox
 
Join Date: Jan 2007
Posts: 109
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via AIM to scandalous Send a message via MSN to scandalous
Default

Something is funny and I cant seem to laugh at my self. Maybe there is a simple solution in what I am trying to do.

I have 3 Tables I am using:

Table 1:

MFGID-Primary key
Manufacturer
Address etc

Table 2: Parts
MFGID
PartNumber-Primary Key
Description
Price

Table 3: Order Details (No Key)
OrderNumber
PartNumber
(other details)

I am trying to make a form in which I can assign an order number to a part. I have over 5k in parts among 7 manufacturers. I want to be able to have the MFGID ComboBox be the filter for the parts that are listed in the Part# Combobox while still autopopulating the "Description" and "Price".

I hope someone can help me.




 
Old January 26th, 2007, 05:06 PM
Friend of Wrox
 
Join Date: Jan 2007
Posts: 109
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via AIM to scandalous Send a message via MSN to scandalous
Default

mmcdonal-

Thanks for helping me out but I was typing up more information and saw you posted again please let me know if I am heading in the right direction.






Similar Threads
Thread Thread Starter Forum Replies Last Post
Help me to DO Stored Procedures msbsam SQL Server 2000 3 October 23rd, 2006 01:54 PM
Store Procedures joeshea Classic ASP Databases 1 July 20th, 2006 01:02 AM
Store Procedures ! augustine SQL Server 2000 1 September 15th, 2004 01:29 PM
Regarding Procedures spraveens MySQL 1 March 10th, 2004 10:08 AM
Right Security Procedures Walden SQL Server 2000 0 November 12th, 2003 11:09 AM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.