UtterAccess.com
X   Site Message
(Message will auto close in 2 seconds)

Welcome Guest ( Log In | Register )

 
Reply to this topicStart new topic
> Cascade Code And Error Msg Re Ole, Office 2010    
 
   
cpetermann
post Apr 3 2012, 02:40 PM
Post #1

UtterAccess Editor
Posts: 4,804
From: Omaha, NE USA



Thought I had conquered the Cascading "beast" however ...
CODE
Private Sub cboEmpPosition_AfterUpdate()
'Update row source of the cboSupervisor combo box.
'When the user makes a selection in the cboEmpPosition combo box
'SQL rowsource to build for cboSupervisor
Dim strSQL As String
'Define the SQL to use based on what the user selects in cboEmpPosition
strSQL = "SELECT qrySupervisors.EmpID, qrySupervisors.EmpName, tblPositionsReportTo.RptstoID, tblPositionsReportTo.PositionID AS EmpPosition " & vbCrLf & _
"FROM qrySupervisors INNER JOIN tblPositionsReportTo ON qrySupervisors.PositionID = tblPositionsReportTo.RptstoID " & vbCrLf & _
"WHERE (((tblPositionsReportTo.PositionID)=[Forms]![frmEmployees]![frmEmpHistory_sub].[Form]![cboEmpPosition]));"

Me.Parent!cboSupervisor.RowSource = strSQL
Me.Parent!cboSupervisor.Requery
End Sub


Updating this cbo Results in:
QUOTE
The expression AfterUpdate you entered as the event property setting produced the following error:
A Problem ocurred while "thedb" was communicating with the Ole object or Activex Control.


Have the following References checked:
VB for Applications
MS Access 14.0 Object Library
OLE Automation
MS Office 14.0 Access db engine Object Library
What else do I need to do or try?
Go to the top of the page
 
+
pere_de_chipstic...
post Apr 3 2012, 03:21 PM
Post #2

UtterAccess VIP
Posts: 7,646
From: South coast, England



Hi Cynthia (IMG:style_emoticons/default/wavehi.gif)

Can't see much wrong with the code except you do not need the vbcrlf, and you can change the reference to cboempposition

Try:
CODE
strSQL = "SELECT qrySupervisors.EmpID, qrySupervisors.EmpName, tblPositionsReportTo.RptstoID, tblPositionsReportTo.PositionID AS EmpPosition " & _
         "FROM qrySupervisors INNER JOIN tblPositionsReportTo ON qrySupervisors.PositionID = tblPositionsReportTo.RptstoID " & _
         "WHERE (((tblPositionsReportTo.PositionID)=" & Forms!frmEmployees!frmEmpHistory_sub.Form!cboEmpPosition & "));"


hth
Go to the top of the page
 
+
ToddW
post Apr 3 2012, 03:21 PM
Post #3

UtterAccess Addict
Posts: 266



I haven't gotten that particular error before, but sometimes I get other weird errors I can't decipher that start with "The expression AfterUpdate you entered as the event property setting produced the following error:"...

When I do, I cut out my whole procedure, save it, then paste it back in and save it again, and then it magically works. Worth trying.
Go to the top of the page
 
+
ToddW
post Apr 3 2012, 03:24 PM
Post #4

UtterAccess Addict
Posts: 266



After looking deeper, why do you even set the rowsource in your code? Why don't you just assign that to the rowsource property directly and save it that way?
Go to the top of the page
 
+
cpetermann
post Apr 3 2012, 03:38 PM
Post #5

UtterAccess Editor
Posts: 4,804
From: Omaha, NE USA



Hi Bernie! (IMG:style_emoticons/default/wavehi.gif)

Hi Todd! (IMG:style_emoticons/default/wavehi.gif)


Tried Todd's suggestion, which did get rid of the error msg,-- Thanks, Todd!!

Thanks Bernie, however, the cboSupervisor still isn't getting its RowSource from the strSQL. (IMG:style_emoticons/default/iconfused.gif)
cboSupervisor is a bound control-- but that shouldn't make a difference should it?

Sometimes what seems like it should be simple, trips me up! (IMG:style_emoticons/default/laugh.gif)

Go to the top of the page
 
+
pere_de_chipstic...
post Apr 3 2012, 03:47 PM
Post #6

UtterAccess VIP
Posts: 7,646
From: South coast, England



Hi Cynthia

I'd have to see your db to see why it's not setting the rowsource, the implication is the problem is in
CODE
Me.Parent!cboSupervisor.RowSource = strSQL
Me.Parent!cboSupervisor.Requery


If you want to post your db, I'd be happy to take a look.

Todd's suggestion will of course work; I'd assumed, as you are dynamically loading the row source, that you needed to change either the criteria of the combo box or even, in some scenarios, the complete SQL. If the row source does not change then better to leave it fixed in the design, with an appropriate requery when the criteria changes or on the 'On Enter' event.

Cheers.
Go to the top of the page
 
+
ToddW
post Apr 3 2012, 03:49 PM
Post #7

UtterAccess Addict
Posts: 266



Forgot to mention that when you paste it back in, you might have to go back to the event property and double click there again to fill in the [Event procedure] if it disappeared.
Go to the top of the page
 
+
cpetermann
post Apr 3 2012, 04:21 PM
Post #8

UtterAccess Editor
Posts: 4,804
From: Omaha, NE USA



Bernie,

This db is one I was trying to help an op get normalized.

The form is frmEmployees
on the Employee History tab.

I did notice another issue-- whenever I selected an Event, the code window opened,
but the Private_Sub etc and End Sub lines weren't present.
C & R'd, closed, re-opened-- same problem.

Imported everything into a new db--
The Private_Sub etc are now displayed--
pasted the code and am now getting another error.

I know that I've overlooked something simple with this AfterUpdate Event (IMG:style_emoticons/default/dazed.gif)
Sounds like I'm whining..maybe I need a nap!!! (IMG:style_emoticons/default/laugh.gif)
Attached File(s)
Attached File  ke4peo_db.zip ( 595.51K ) Number of downloads: 3
 
Go to the top of the page
 
+
ToddW
post Apr 3 2012, 04:46 PM
Post #9

UtterAccess Addict
Posts: 266



I get 'unrecognized database format' when i try to open it.
Go to the top of the page
 
+
pere_de_chipstic...
post Apr 3 2012, 04:57 PM
Post #10

UtterAccess VIP
Posts: 7,646
From: South coast, England



Hi Cynthia

Looking at the db, there is a combo control cboSupervisor on the same form as cboEmpPosition; should the code be simply:
CODE
strSQL = "SELECT qrySupervisors.EmpID, qrySupervisors.EmpName, tblPositionsReportTo.RptstoID, tblPositionsReportTo.PositionID AS EmpPosition " & _
         "FROM qrySupervisors INNER JOIN tblPositionsReportTo ON qrySupervisors.PositionID = tblPositionsReportTo.RptstoID " & _
         "WHERE (((tblPositionsReportTo.PositionID)=" & Me.cboEmpPosition & "));"
Me.cboSupervisor.RowSource = strSQL
Me.cboSupervisor.Requery


Another possible problem is that if the Employee history is a continuous form cboSupervisor will only show an entry for records with the selected position.

hth
Go to the top of the page
 
+
cpetermann
post Apr 3 2012, 05:23 PM
Post #11

UtterAccess Editor
Posts: 4,804
From: Omaha, NE USA



Thanks for taking a look, Bernie.

I'll give that a go, and let you know!!
Go to the top of the page
 
+
pere_de_chipstic...
post Apr 3 2012, 05:26 PM
Post #12

UtterAccess VIP
Posts: 7,646
From: South coast, England



(IMG:style_emoticons/default/thumbup.gif)

I'm leaving the UA office now for some shut eye (IMG:style_emoticons/default/sleeping.gif) will take a look in the morning!
Hope it goes well.

Go to the top of the page
 
+
pere_de_chipstic...
post Apr 4 2012, 04:59 AM
Post #13

UtterAccess VIP
Posts: 7,646
From: South coast, England



Hi Cynthia

I've taken another look at the db.

In the set up you have, then Todd's suggestion of having the row source hard wired is the appropriate implementation as the criteria for the position ID will change for each record. The way to handle this would probably be best handled by a combo requery in the 'On Enter' event of the combo box . The problem is that whenever an event is triggered you get the error message you described - whether or not there is code in the event.

I suspect that the sub form has been corrupted and will need to be redesigned from scratch.

I also noticed that the sub form event window did not have the Private_Sub etc and End Sub lines present. Investigating this resulted in the VBA code window returning a completely empty window, further adding to the suspicion that the db has become corrupted.

hth
Go to the top of the page
 
+
cpetermann
post Apr 4 2012, 05:26 AM
Post #14

UtterAccess Editor
Posts: 4,804
From: Omaha, NE USA



Bernie,

Have simplified the subform design and it seems to work now.
Decided that it wasn't up to me to decide if cboPosition needed an AfterUpdate Event--
will wait to see if the op decides that something like this is needed.

C& Rd, Closed & reopened--
When I changed the view to single form, the Private_Sub etc and End Sub lines were present --Corruption? (IMG:style_emoticons/default/iconfused.gif)

re Todd's suggestion-- I missed that,(Sorry Todd (IMG:style_emoticons/default/blush.gif) ) thanks for pointing it out-- I'll give that a try!





Go to the top of the page
 
+
pere_de_chipstic...
post Apr 4 2012, 05:40 AM
Post #15

UtterAccess VIP
Posts: 7,646
From: South coast, England



Hi Cynthia

QUOTE
When I changed the view to single form, the Private_Sub etc and End Sub lines were present

You shouldn't need to change between single or continuous form the VBA sub should still appear correctly,

Also if you 'hard wire' the SQL row source of the combo box, then that will avoid needing the 'cboPosition' to rewrite the row source of 'cboSupervisor' but you will still need to requery 'cboSupervisor' when you change the record or change 'cboPosition'. On my tests any event triggering resulted in the same error message as you had. So, yes, I still believe the db has some corruption!

hth
Go to the top of the page
 
+

Thank you for your support! Reply to this topicStart new topic

Jump To Forum:
 



RSS Go to Top  ·  Lo-Fi Version Time is now: 19th June 2013 - 01:56 AM