mainform control AfterUpdate problem? 
Author Message
 mainform control AfterUpdate problem?

I have a mainform that has a combo box control: Combo65.  There is a multi
tab subform that reflects the records that are linked to what is selected in
Combo65.  I previously had a control that enabled users to "scroll" through
the available "ProjectName" field's records with Previous Record and Next
Record command buttons.  That worked successfully, but as the ProjectName
records became abundant, I decided to change it to a drop-down list to make
that process faster/easier.

The AfterUpdate event for Combo65 is as follows:
Private Sub Combo65_AfterUpdate()
    Me.RecordsetClone.FindFirst "ProjectName = '" & Combo65 & "'"
    Me.Bookmark = Me.RecordsetClone.Bookmark
End Sub

Now when a ProjectName is selected from the drop-down, I get the following
error:
Run-time error '3077':
Syntax error (missing operator) in expression.

When I Debug, it highlights the second line:  MeRecordsetClone.FindFirst....

Not being a VB expert, I am unable to identify why this doesn't work.  Can
anyone help?  Any feedback is greatly appreciated!



Mon, 02 Jun 2008 23:05:04 GMT  
 mainform control AfterUpdate problem?

Quote:

>I have a mainform that has a combo box control: Combo65.  There is a multi
>tab subform that reflects the records that are linked to what is selected in
>Combo65.  I previously had a control that enabled users to "scroll" through
>the available "ProjectName" field's records with Previous Record and Next
>Record command buttons.  That worked successfully, but as the ProjectName
>records became abundant, I decided to change it to a drop-down list to make
>that process faster/easier.

>The AfterUpdate event for Combo65 is as follows:
>Private Sub Combo65_AfterUpdate()
>    Me.RecordsetClone.FindFirst "ProjectName = '" & Combo65 & "'"
>    Me.Bookmark = Me.RecordsetClone.Bookmark
>End Sub

>Now when a ProjectName is selected from the drop-down, I get the following
>error:
>Run-time error '3077':
>Syntax error (missing operator) in expression.

I think you would get that error if the combo box's value is
a name like Bob's Barber Shop. This particular issue can be
avoided by using the Replace function to double up the ' in
the name.

But, I thought the record you want to find are in the
subform.  Your code is searching for the record in the main
form.  If that's the case, You want something more like:

With Me.subform.Form.RecordsetClone
        .FindFirst "ProjectName = '" & Replace(Combo65, "'","''")
& "'"
        Me.subform.Form.Bookmark = .Bookmark
End With

--
Marsh
MVP [MS Access]



Tue, 03 Jun 2008 00:31:44 GMT  
 mainform control AfterUpdate problem?
Does the code you suggested still belong in the AfterUpdate event?  I tried
it bit now get a series of different errors.  

Just to clarify, the record in the main form is a name such as Bob's Barber
Shop.  But why the error now?  The AfterUpdate event could be the same
regardless of how the control functions shouldn't it?... since it fires after
a selection is made.

I also don't necessarily want to "find" a record in the subform as you
responded.  I just want the records to relate to the mainform.

My initial error led me to believe I was missing an operator, so I was
thinking that code was very close to being right.  Again...any feedback is
appreciated!
Kevin

Quote:


> >I have a mainform that has a combo box control: Combo65.  There is a multi
> >tab subform that reflects the records that are linked to what is selected in
> >Combo65.  I previously had a control that enabled users to "scroll" through
> >the available "ProjectName" field's records with Previous Record and Next
> >Record command buttons.  That worked successfully, but as the ProjectName
> >records became abundant, I decided to change it to a drop-down list to make
> >that process faster/easier.

> >The AfterUpdate event for Combo65 is as follows:
> >Private Sub Combo65_AfterUpdate()
> >    Me.RecordsetClone.FindFirst "ProjectName = '" & Combo65 & "'"
> >    Me.Bookmark = Me.RecordsetClone.Bookmark
> >End Sub

> >Now when a ProjectName is selected from the drop-down, I get the following
> >error:
> >Run-time error '3077':
> >Syntax error (missing operator) in expression.

> I think you would get that error if the combo box's value is
> a name like Bob's Barber Shop. This particular issue can be
> avoided by using the Replace function to double up the ' in
> the name.

> But, I thought the record you want to find are in the
> subform.  Your code is searching for the record in the main
> form.  If that's the case, You want something more like:

> With Me.subform.Form.RecordsetClone
>    .FindFirst "ProjectName = '" & Replace(Combo65, "'","''")
> & "'"
>    Me.subform.Form.Bookmark = .Bookmark
> End With

> --
> Marsh
> MVP [MS Access]



Tue, 03 Jun 2008 05:01:03 GMT  
 mainform control AfterUpdate problem?
Sheesh Kevin, "a series of different errors" is much of a
clue.  Did you use the name of your subform control where I
use the generic term "subform"?

Regardless, if you want the subform to be filtered to just
the records that match the combo box, then you do not need
any code in the AfterUpdate event.  Instead, try setting the
subform control's Link Master/Child properties to the
ProjectName field.
--
Marsh
MVP [MS Access]

Quote:

>Does the code you suggested still belong in the AfterUpdate event?  I tried
>it bit now get a series of different errors.  

>Just to clarify, the record in the main form is a name such as Bob's Barber
>Shop.  But why the error now?  The AfterUpdate event could be the same
>regardless of how the control functions shouldn't it?... since it fires after
>a selection is made.

>I also don't necessarily want to "find" a record in the subform as you
>responded.  I just want the records to relate to the mainform.

>My initial error led me to believe I was missing an operator, so I was
>thinking that code was very close to being right.


>> >I have a mainform that has a combo box control: Combo65.  There is a multi
>> >tab subform that reflects the records that are linked to what is selected in
>> >Combo65.  I previously had a control that enabled users to "scroll" through
>> >the available "ProjectName" field's records with Previous Record and Next
>> >Record command buttons.  That worked successfully, but as the ProjectName
>> >records became abundant, I decided to change it to a drop-down list to make
>> >that process faster/easier.

>> >The AfterUpdate event for Combo65 is as follows:
>> >Private Sub Combo65_AfterUpdate()
>> >    Me.RecordsetClone.FindFirst "ProjectName = '" & Combo65 & "'"
>> >    Me.Bookmark = Me.RecordsetClone.Bookmark
>> >End Sub

>> >Now when a ProjectName is selected from the drop-down, I get the following
>> >error:
>> >Run-time error '3077':
>> >Syntax error (missing operator) in expression.


>> I think you would get that error if the combo box's value is
>> a name like Bob's Barber Shop. This particular issue can be
>> avoided by using the Replace function to double up the ' in
>> the name.

>> But, I thought the record you want to find are in the
>> subform.  Your code is searching for the record in the main
>> form.  If that's the case, You want something more like:

>> With Me.subform.Form.RecordsetClone
>>        .FindFirst "ProjectName = '" & Replace(Combo65, "'","''")
>> & "'"
>>        Me.subform.Form.Bookmark = .Bookmark
>> End With



Tue, 03 Jun 2008 07:06:33 GMT  
 
 [ 4 post ] 

 Relevant Pages 

1. Calendar Control AfterUpdate event problem

2. Calendar Control AfterUpdate event problem

3. Subform control referring to control on mainform

4. MainForm,2Subforms,UnboundCombo,NotOnLIst, adds and requeries but MainFORM doesnt reflect

5. MainForm,2Subforms,UnboundCombo,NotOnLIst, adds and requeries but MainFORM doesnt reflect

6. SetFocus Problem + AfterUpdate Problem

7. listbox on tab control to update mainform recordset using ADO

8. Controlling subform record from mainform

9. Moving from Subform to mainform controls.

10. Calendar Control on MainForm with DateField on Subform


 
Powered by phpBB® Forum Software © phpBB Group