Solved

CBO box not selecting record on subform

Posted on 2008-10-22
13
452 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
Do You Know the 4 Main Threat Actor Types?

Do you know the main threat actor types? Most attackers fall into one of four categories, each with their own favored tactics, techniques, and procedures.

 

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

Complete VMware vSphere® ESX(i) & Hyper-V Backup

Capture your entire system, including the host, with patented disk imaging integrated with VMware VADP / Microsoft VSS and RCT. RTOs is as low as 15 seconds with Acronis Active Restore™. You can enjoy unlimited P2V/V2V migrations from any source (even from a different hypervisor)

Join & Write a Comment

Regardless of which version on MS Access you are using, one of the harder data-entry forms to create is one where most data from previous entries needs to be appended to new records, especially when there are numerous fields and records involved.  W…
I originally created this report in Crystal Reports 2008 where there is an option to underlay sections. I initially came across the problem in Access Reports where I was unable to run my border lines down through the entire page as I was using the P…
Learn how to number pages in an Access report over each group. Activate two pass printing by referencing the pages property: Add code to the Page Footers OnFormat event to capture the pages as there occur for each group. Use the pages property to …
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…

744 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

14 Experts available now in Live!

Get 1:1 Help Now