Hi Doug
* Changed my ComboBox to DonatedBy [as suggested]
* Put the event procedure into the Subform OnCurrent - as follows:
Private Sub Form_Current()
Dim strRowSource As String
If IsNull(Me.CG1FirstName) = False Then
strRowSource = strRowSource & Me.CG1FirstName & ";"
If IsNull(Me.CG2FirstName) = False Then
strRowSource = strRowSource & Me.CG2FirstName & ";"
strRowSource = strRowSource & Me.CG1FirstName & " and " &
Me.CG2FirstName & ";"
End If
Else
If IsNull(Me.CG2FirstName) = False Then
strRowSource = strRowSource & Me.CG2FirstName & ";"
End If
End If
If Len(strRowSource) > 0 Then
strRowSource = Left$(strRowSource, Len(strRowSource) - 1)
Me.DonatedBy.RowSourceType = "Value List"
Me.DonatedBy.RowSource = strRowSource
Else
Me.DonatedBy.RowSourceType = ""
Me.DonatedBy.RowSource = ""
End If
Though is till comes back with the error:
'The expression OnCurrent you entered as the event property setting
produced
the following error: A problem occurred while MSFT A ... was communicating
with the OLE server or ActiveX Control
* The expression may not result in the name of a macro, the name of a
user-defined function or [Event Procedure]
* or there may have been an error evaluationing the function, event or
macro.
--
Sue Compelling
:
Sorry: I only typically get to this particular newsgroup once a day.
Looking more closely at your code, it looks as though you've named your
combobox Donated By, with a space in there. That means that Me.Donated
By.RowSourceType and Me.Donated By.RowSource won't work: the embedded
space
is throwing them off.
Either rename your combobox to remove the space (my recommendation), or
try
Me.Donated_By.RowSourceType
--
Doug Steele, Microsoft Access MVP
(no e-mails, please!)
message
Hi Doug - I also meant to say, I thought you'd given up on me [as I
hadn't
heard anything for a day]. I wasn't quite sure what the protocol is in
these
situations, so made another post. Please don't leave me - I want to
crack
this.
--
Sue Compelling
:
I took the event procedure out of the OnCurrent of the subform (and
put
in in
the OnEnter of the ComboBox) .... is this a bad thing? Is this where
the
mistake is? When had I tried this same code on the OnCurrent of the
subform
though it came back with the error I previously described.
--
Sue Compelling
:
Given that you've named the routine Donated_By_Enter(), what are you
putting
in the OnCurrent events?
--
Doug Steele, Microsoft Access MVP
(no e-mails, please!)
message
Oh Doug - grrrrrrrrrrr
It still didn't work - I took the event procedure OFF the
Donations
SubForm
'OnCurrent' and put it on the Donated By ComboBox 'On Enter',
though
it
comes
up with the same error as before. This is the code exactly as
it's
in the
event procedure. I don't want to give up [self taught and all]
....
though
I'm willing to persevere if you are... [Is there additional info
you
need
from me that would help?] - does this forum allow screen shots to
be
attached?
Private Sub Donated_By_Enter()
Dim strRowSource As String
If IsNull(Me.CG1FirstName) = False Then
strRowSource = strRowSource & Me.CG1FirstName & ";"
If IsNull(Me.CG2FirstName) = False Then
strRowSource = strRowSource & Me.CG2FirstName & ";"
strRowSource = strRowSource & Me.CG1FirstName & " and " &
Me.CG2FirstName & ";"
End If
Else
If IsNull(Me.CG2FirstName) = False Then
strRowSource = strRowSource & Me.CG2FirstName & ";"
End If
End If
If Len(strRowSource) > 0 Then
strRowSource = Left$(strRowSource, Len(strRowSource) - 1)
Me.Donated By.RowSourceType = "Value List"
Me.Donated By.RowSource = strRowSource
Else
Me.Donated By.RowSourceType = ""
Me.Donated By.RowSource = ""
End If
End Sub
--
Sue Compelling
:
Slight typo there: the line should have been
strRowSource = Left$(strRowSource, Len(strRowSource)-1)
(it's taking the superfluous final semicolon off the string)
See whether making that correction solves the problem.
If not, paste the entire code you've got in the Event.
--
Doug Steele, Microsoft Access MVP
(no e-mails, please!)
in
message
Hi Doug - yep, ['patience of a Saint Doug']. I copied the code
(closed
the
bracket on the Left$(strR - line) though ACCESS came back with
the
following
error:
'The expression OnCurrent you entered as the event property
setting
produced
the following error: A problem occurred while MSFT A ... was
communicating
with the OLE server or ActiveX Control
* The expression may not result in the name of a macro, the
name
of a
user-defined function or [Event Procedure]
* or there may have been an error evaluationing the function,
event or
macro.
What now?
--
Sue Compelling
:
Ah, I'm with you now.
Try using something like the following in the form's OnCurrent
event:
Dim strRowSource As String
If IsNull(Me.CG1FirstName) = False Then
strRowSource = strRowSource & Me.CG1FirstName & ";"
If IsNull(Me.CG2FirstName) = False Then
strRowSource = strRowSource & Me.CG2FirstName & ";"
strRowSource = strRowSource & Me.CG1FirstName & " and
"
&
Me.CG2FirstName & ";"
End If
Else
If IsNull(Me.CG2FirstName) = False Then
strRowSource = strRowSource & Me.CG2FirstName & ";"
End If
End If
If Len(strRowSource) > 0 Then
strRowSource = Left$(strR
Me.MyComboBox.RowSourceType = "Value List"
Me.MyComboBox.RowSource = strRowSource
Else
Me.MyComboBox.RowSourceType = ""
Me.MyComboBox.RowSource = ""
End If
--
Doug Steele, Microsoft Access MVP
(no e-mails, please!)
"Sue Compelling" <
[email protected]>
wrote
in
message
Hi Douglas
My Student form [Tab Control Page] has a number of fields,
capturing
student
details and their caregivers details. In this form it
includes
the
fields
[CG1FirstName],[CG1LastName], [CG2FirstName], [CG1LastName].
Then on the next Tab Conrol Page - I have included a subform
for
donations.
This subform has the following fields:
StudentID
DonationID
Funds [ComboBox to select]
Amount
Date
DonatedBy