Solved

CBO box not selecting record on subform

Posted on 2008-10-22
13
463 Views
Last Modified: 2013-11-25
I am tring to get a subform to go to the correct record when I change the value in a cbo box, but not happening.
Private Sub cboBranchNo_Click()
Dim rst As Recordset
Dim strSearchName As String, strFormName As String
strFormName = Me.Name
    Set rst = Me.sfmAMLItems.RecordsetClone
    strSearchName = Str(Me!cboBranchNo)
    rst.FindFirst "BR_NMR = " & strSearchName
        If rst.NoMatch Then
            MsgBox "Record not found"
        Else
            Me.Bookmark = rst.Bookmark
        End If
    rst.Close
 
End Sub

Open in new window

0
Comment
Question by:ssmith94015
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 8
  • 5
13 Comments
 
LVL 75
ID: 22781932


Private Sub cboBranchNo_Click()
Dim rst As Recordset
Dim strSearchName As String, strFormName As String
strFormName = Me.Name
    Set rst = Me.sfmAMLItems.RecordsetClone
    strSearchName = Str(Me!cboBranchNo)
    rst.FindFirst "BR_NMR = " & Chr(34) & strSearchName & Chr(34)   ' ** change here
        If rst.NoMatch Then
            MsgBox "Record not found"
        Else
            Me.Bookmark = rst.Bookmark
        End If
    rst.Close
 
End Sub
0
 

Author Comment

by:ssmith94015
ID: 22781963
The main form is not recogniing the exitance of the subform  I get Method or data member not found.
0
 

Author Comment

by:ssmith94015
ID: 22781968
I also moved it to the after update event
0
Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
LVL 75

Accepted Solution

by:
DatabaseMX (Joe Anderson - Microsoft MVP, Access and Data Platform) earned 500 total points
ID: 22781995
Private Sub cboBranchNo_Click()
Dim rst As Recordset
Dim strSearchName As String, strFormName As String
strFormName = Me.Name
    Set rst = Me.sfmAMLItems.Form.RecordsetClone           ' * change here also
    strSearchName = Str(Me!cboBranchNo)
    rst.FindFirst "BR_NMR = " & Chr(34) & strSearchName & Chr(34)   ' ** change here
        If rst.NoMatch Then
            MsgBox "Record not found"
        Else
            Me.Bookmark = rst.Bookmark
        End If
    rst.Close
 
End Sub
0
 
LVL 75
ID: 22781997
Is this code on the Main form ?

mx
0
 

Author Comment

by:ssmith94015
ID: 22782027
Yes. The main form is an unbound form with only two controls, the combo box to select the records and a text box that holds an email address where the reocrds will be sent.
0
 

Author Comment

by:ssmith94015
ID: 22782039
I have to sign off until tomorrow.  Will come back to this issue then,.
0
 
LVL 75
ID: 22782045
Did you make the change from my last post?

Set rst = Me.sfmAMLItems.Form.RecordsetClone           ' * change here also

                                     -----^^^^^-------  add the Form object

mx
0
 

Author Comment

by:ssmith94015
ID: 22789162
I think, with you help, I figured it out.  Could it be that the combo box is unbound and the sub-form does not really have a relationship with the "main" form?  I played with it a little this morning, deleted the sub-form and recreated it.  I got the wizrd box asking me for the relationsihp and when I selected to define my own, the only control from the main form was the email address box, the combo did not appear as a selection.  I think that it the main issue and I need to redesign the form.  What I am trying to do is have the user distiall the rows in the subform to those that need to go to a partricular branch, so I need to have the combo box's data source a distince list of the branch numbers rather than what I have now.  I need to re-design the underlying tables to connect the detail rows with the e-mail addresses via the branch numbers.
0
 
LVL 75
ID: 22789219
"Could it be that the combo box is unbound and the sub-form does not really have a relationship with the "main" form?"

Ummm ... I don't think so.  That would not matter.  It's something else.

mx
0
 

Author Comment

by:ssmith94015
ID: 22789253
AAARRGGG, I would hoping that was it.  Problem now is I have been pulled onto another issue and cannot get back to this until tomorrow again.
0
 

Author Comment

by:ssmith94015
ID: 22800168
I give up. sometihng to (#^^& smple and I can't get it to work.  It looks fine, looks like other things I have done, but refuses to cooperate and I am losing patience.  But your suggestion did work as I have used them in other places, I don't know why and I don't have the time to devote to it.  I will have to think of something else.  

Thanks for trying to help.
0
 

Author Closing Comment

by:ssmith94015
ID: 31508999
DatabaseMX, thank for trying to help.  I don't know what theheck is wrong but I have to work around it to get this out the door.  It is sucha  simple thing but just won't work.
0

Featured Post

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This article describes two methods for creating a combo box that can be used to add new items to the row source -- one for simple lookup tables, and one for a more complex row source where the new item needs data for several fields.
This article describes a method of delivering Word templates for use in merging Access data to Word documents, that requires no computer knowledge on the part of the recipient -- the templates are saved in table fields, and are extracted and install…
With Microsoft Access, learn how to specify relationships between tables and set various options on the relationship. Add the tables: Create the relationship: Decide if you’re going to set referential integrity: Decide if you want cascade upda…
Polish reports in Access so they look terrific. Take yourself to another level. Equations, Back Color, Alternate Back Color. Write easy VBA Code. Tighten space to use less pages. Launch report from a menu, considering criteria only when it is filled…

691 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question