-
Sep 9th, 2017, 12:01 AM
#1
Thread Starter
New Member
Passing ComboBox from One Page to Other Page
Hi,
This is my first post in this forum.
Viewed certain post but could not get the result, so thought of a new post.
I am using a software with VBA as component.
I have one common page where all function are programmed and it keeps on running in background.
The things I am trying has already worked with other PCs/Laptop with same configuration and version, but somehow not working with new system..
Now problem is that I want to add certain items into combobox from result of an SQL query based recordset.
Original function in background page "X" is like this...Public function Fn1 (MyCombo as ComboBox, Optional Item as string = "Material")
...
...
...
...
MyCombo.AddItem (UCase (RS(0))) --Line giving error "Server threw an exception
...
End function
Now Calling line in main page "PR" is like this.
X.Fn1 CB1,"MaterialCode"
To correct this, I tried in background function like: PR.Elements(CB1).AddItem (UCasae(RS(0))) -- This worked fine.
But I can't do like this becasue multiple pages calls this function with different CB names and optional parameter "Item".
Please suggest...
-
Sep 9th, 2017, 06:21 PM
#2
Re: Passing ComboBox from One Page to Other Page
in vba the combobox object is usually a forms2 combobox, try changing like
Code:
Public function Fn1 (MyCombo as MSForms.ComboBox, Optional Item as string = "Material")
though i would have expected a type mismatch error when the procedure was called
did you check if the recordset actually contained some redords?
i do my best to test code works before i post it, but sometimes am unable to do so for some reason, and usually say so if this is the case.
Note code snippets posted are just that and do not include error handling that is required in real world applications, but avoid On Error Resume Next
dim all variables as required as often i have done so elsewhere in my code but only posted the relevant part
come back and mark your original post as resolved if your problem is fixed
pete
-
Sep 10th, 2017, 11:33 PM
#3
Thread Starter
New Member
Re: Passing ComboBox from One Page to Other Page
Originally Posted by westconn1
in vba the combobox object is usually a forms2 combobox, try changing like
Code:
Public function Fn1 (MyCombo as MSForms.ComboBox, Optional Item as string = "Material")
though i would have expected a type mismatch error when the procedure was called
did you check if the recordset actually contained some redords?
First of all, Thanks for the response.
I tried MSForms.ComboBox as suggested, but didn't work.
Same problem.
Yes, Dataset is returning 101 rows.
And there is no typo error as well.
The exact error is as follows.
Err.No: -2147417851
Err.Description: Automation Error. The server threw an exception.
Additional info:
If I directly use, Page.Elements(ComboBox).AddItem ("text"), This works well...
My doubt is ComboBox is not passing from Calling page to Called function page.
But the same code is working in other PC.
This is new PC, so I doubt, some window updates might be causing problem.
Any other suggestion please.
-
Sep 12th, 2017, 04:26 PM
#4
Re: Passing ComboBox from One Page to Other Page
can you determine if the passed combobox is the proper object?
maybe
Code:
msgbox typename(mycombo)
i do my best to test code works before i post it, but sometimes am unable to do so for some reason, and usually say so if this is the case.
Note code snippets posted are just that and do not include error handling that is required in real world applications, but avoid On Error Resume Next
dim all variables as required as often i have done so elsewhere in my code but only posted the relevant part
come back and mark your original post as resolved if your problem is fixed
pete
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|