Solved

CBO box not selecting record on subform

Posted on 2008-10-22
13
453 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
  • 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
 
LVL 75

Accepted Solution

by:
DatabaseMX (Joe Anderson - Access MVP) 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
Ransomware-A Revenue Bonanza for Service Providers

Ransomware – malware that gets on your customers’ computers, encrypts their data, and extorts a hefty ransom for the decryption keys – is a surging new threat.  The purpose of this eBook is to educate the reader about ransomware attacks.

 

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

Backup Your Microsoft Windows Server®

Backup all your Microsoft Windows Server – on-premises, in remote locations, in private and hybrid clouds. Your entire Windows Server will be backed up in one easy step with patented, block-level disk imaging. We achieve RTOs (recovery time objectives) as low as 15 seconds.

Question has a verified solution.

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

Introduction The Visual Basic for Applications (VBA) language is at the heart of every application that you write. It is your key to taking Access beyond the world of wizards into a world where anything is possible. This article introduces you to…
In a multiple monitor setup, if you don't want to use AutoCenter to position your popup forms, you have a problem: where will they appear?  Sometimes you may have an additional problem: where the devil did they go?  If you last had a popup form open…
Using Microsoft Access, learn some simple rules for how to construct tables in a relational database. Split up all multi-value fields into single values: Split up fields that belong to other things into separate tables: Make sure that all record…
Access reports are powerful and flexible. Learn how to create a query and then a grouped report using the wizard. Modify the report design after the wizard is done to make it look better. There will be another video to explain how to put the final p…

863 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

Need Help in Real-Time?

Connect with top rated Experts

16 Experts available now in Live!

Get 1:1 Help Now