By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
446,164 Members | 1,001 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 446,164 IT Pros & Developers. It's quick & easy.

What syntax to call a procedure in a sub-form?

Expert 100+
P: 446
Hi
Using Access 2002 on XP

I want to run the subroutine of the After Update event of a control in a sub form after 'inserting' a value from elsewhere.

My main form is [OLStart] and the subform is [OLSelect], the control [TypeID] is a combobox and I an inserting the integer value [iTid]. I've made the AfterUpdate event 'Public' and am using the following code.

Expand|Select|Wrap|Line Numbers
  1. 'insert value into TypeID in OLSelect
  2. [OLSelect].Form![TypeID] = iTid
  3. 'run after_update event
  4. Call Forms.[OLStart].[OLSelect].Form.TypeID_AfterUpdate
The value inserts OK but the after update event does not run (not surprising) but when I add the line to force it I am getting the error message "Object does not support this property or method"

I've used similar syntax to insert a value in a control then run an On_Click event on a command button, so why is it not working with my combo-box?

Anybody any ideas?
Dec 6 '07 #1
Share this Question
Share on Google+
5 Replies


JustJim
Expert 100+
P: 407
Hi
Using Access 2002 on XP

I want to run the subroutine of the After Update event of a control in a sub form after 'inserting' a value from elsewhere.

My main form is [OLStart] and the subform is [OLSelect], the control [TypeID] is a combobox and I an inserting the integer value [iTid]. I've made the AfterUpdate event 'Public' and am using the following code.

Expand|Select|Wrap|Line Numbers
  1. 'insert value into TypeID in OLSelect
  2. [OLSelect].Form![TypeID] = iTid
  3. 'run after_update event
  4. Call Forms.[OLStart].[OLSelect].Form.TypeID_AfterUpdate
The value inserts OK but the after update event does not run (not surprising) but when I add the line to force it I am getting the error message "Object does not support this property or method"

I've used similar syntax to insert a value in a control then run an On_Click event on a command button, so why is it not working with my combo-box?

Anybody any ideas?
I think that the problem lies in the way that you have to update combo-boxes. You can't just assign a value to it like a text box, Check out this recent thread for more details.

Jim
Dec 7 '07 #2

Expert 100+
P: 446
I think that the problem lies in the way that you have to update combo-boxes. You can't just assign a value to it like a text box, Check out this recent thread for more details.

Jim
Thanks Jim, that got me thinking.

Stuffing the value in does work, i.e. the data is displayed without an error but the message comes when you call the AfterUpdate event, so I changed the code to load the value as the 'Default.' This then works!

Expand|Select|Wrap|Line Numbers
  1. 'insert value into TypeID in OLSelect
  2. [OLSelect].Form![TypeID].DefaultValue = iTid
  3. 'run after_update event
  4. Call [OLSelect].Form.TypeID_AfterUpdate
Prior to this, I had tried creating a dummy text box and a dummy command button and putting a 'MsgBox' in the AfterUpdate/On_Click events and found that the sysntax could be shortened to the above form. The Subs have to be made 'Public' ofcourse.

Thanks again.
Dec 7 '07 #3

JustJim
Expert 100+
P: 407
Thanks Jim, that got me thinking.

Stuffing the value in does work, i.e. the data is displayed without an error but the message comes when you call the AfterUpdate event, so I changed the code to load the value as the 'Default.' This then works!

Expand|Select|Wrap|Line Numbers
  1. 'insert value into TypeID in OLSelect
  2. [OLSelect].Form![TypeID].DefaultValue = iTid
  3. 'run after_update event
  4. Call [OLSelect].Form.TypeID_AfterUpdate
Prior to this, I had tried creating a dummy text box and a dummy command button and putting a 'MsgBox' in the AfterUpdate/On_Click events and found that the sysntax could be shortened to the above form. The Subs have to be made 'Public' ofcourse.

Thanks again.
I would have thought that you would only get one value (iTid) in your combo-box. I'll have to have a play with that!

Jim
Dec 9 '07 #4

Expert 100+
P: 446
I would have thought that you would only get one value (iTid) in your combo-box. I'll have to have a play with that!

Jim
G'day Jim

That was what I wanted. I wasn't trying to change the Row Source, just poke a pre-selected value in. (which is different from your other thread) I was trying to accommodate a 'late' user request and got myself in a pickle.

The truth is, I'm not sure when I should be using dot [.] or pling [!] and could not find a combination that worked.

Taking your suggestion that a combo may behave differently to a text box lead me to confirm the correct syntax with a dummy textbox (I also tested a command button), so the syntax for the after-update had been right from the begining.

Thinking about it afterwards, I have forms on another job where the user can change units of measure between 'mm' and 'inches' selected from a combo, but the default is set programmatically depending upon whether the transaction is for Aluminium or Stainless steel. I think that there I had to 'seed' the combo by poking the DefaultValue, so I should have remembered!

Thanks again.
Dec 10 '07 #5

JustJim
Expert 100+
P: 407
G'day Jim
<snip>
The truth is, I'm not sure when I should be using dot [.] or pling [!] and could not find a combination that worked.
<snip>
Thanks again.
You're not Robinson Crusoe on that one my friend! Check out this thread to see some of the experts scratching their heads (and each others eyes, a bit). Scroll down a bit and there is one explanation of the reasoning, there are others.

Jim
Dec 10 '07 #6

Post your reply

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