Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Select a record in ComboBox to be appear in Subform

Status
Not open for further replies.

quinbe

Programmer
Dec 30, 2004
62
0
0
US
Hi all,
I have a form and a subform having 1-M relationship by Hearder_ID. This what I'm trying to do... I want to type the HeaderName (not Header_ID) in a CboBox to get all detail information which is appear in the subform
The code below I got from faq702-4933, but I cannot figure out what I did wrong.
Anyone please help

Code:
Private Sub Combo6_AfterUpdate()
Dim Header_ID As Integer

Header_ID = Me.Combo6.Column(0)

With Me.[Table2Subform].Form
    .RecordsetClone.FindFirst "Header_ID = " & Header_ID
    If Not .RecordsetClone.NoMatch Then
        .Bookmark = .RecordsetClone.Bookmark
    End If
End With

End Sub
[code]
 
For more information

The error I had is________Run-time error '94':
Invalid use of Null
 
You may try this:
Dim Header_ID As Integer
If Trim(Me!Combo6.Column(0) & "") = "" Then Exit Sub
Header_ID = Me!Combo6.Column(0)

Hope This Helps, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884 or FAQ181-2886
 
Thanks PHV,
I tried the code you post, no matter what HearderName I tried, it still give me deatail of the first record.
The combo box's control source I have set = HeaderName,
Row Source Type = Table/Query
Is there any mistake here???
 
What is the SQL code of Combo6.RowSource ?

Hope This Helps, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884 or FAQ181-2886
 
PHV,
I have a blank there. Is it what I had missed making the code doesn't work???
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top