find a record

S

sam

Hi,
I have an unbound form with a number of combo's. I'm wanting to select from
the combo and populate a number of text boxes. I know I can do it just by
putting a control source in the text box of =cboDem.column(2) but am trying
to work out how to do it with code. I've tried many different ways and just
can't do it. I think I probably need 'find' in there somewhere... I'm
completely lost now. can anyone assist?




Private Sub cboDemo_AfterUpdate()
Dim rs As DAO.Recordset
Set rs = CurrentDb.OpenRecordset("SELECT tblDemo.DemoIDS,
tblClient.Client, tblStoreDetail.ClientNm, tblStoreDetail.StoreNo FROM
(tblDemo LEFT JOIN tblClient ON tblDemo.ClientID = tblClient.ClentIDS) LEFT
JOIN tblStoreDetail ON tblDemo.StoreID = tblStoreDetail.StoreIDS WHERE
(((tblDemo.DemoIDS)=[Forms]![tblScheduling]![cboDemo]));")
With rs
Me.txttest = !StoreNo


End With

'clean up
rs.Close
Set rs = Nothing
End Sub
 
J

Jeanette Cunningham

Sam,
try something like this:

If Not IsNull Me.TheComboName Then
With Me.TheComboName
Me.txtboxA = .Column(1)
Me.txtboxB = .Column(2)
End With
End IF


Jeanette Cunningham
 
S

sam

Thanks Jeanette, I can do it with that method but want to do it using the
recordset
--
Thanks


Jeanette Cunningham said:
Sam,
try something like this:

If Not IsNull Me.TheComboName Then
With Me.TheComboName
Me.txtboxA = .Column(1)
Me.txtboxB = .Column(2)
End With
End IF


Jeanette Cunningham

sam said:
Hi,
I have an unbound form with a number of combo's. I'm wanting to select
from
the combo and populate a number of text boxes. I know I can do it just by
putting a control source in the text box of =cboDem.column(2) but am
trying
to work out how to do it with code. I've tried many different ways and
just
can't do it. I think I probably need 'find' in there somewhere... I'm
completely lost now. can anyone assist?




Private Sub cboDemo_AfterUpdate()
Dim rs As DAO.Recordset
Set rs = CurrentDb.OpenRecordset("SELECT tblDemo.DemoIDS,
tblClient.Client, tblStoreDetail.ClientNm, tblStoreDetail.StoreNo FROM
(tblDemo LEFT JOIN tblClient ON tblDemo.ClientID = tblClient.ClentIDS)
LEFT
JOIN tblStoreDetail ON tblDemo.StoreID = tblStoreDetail.StoreIDS WHERE
(((tblDemo.DemoIDS)=[Forms]![tblScheduling]![cboDemo]));")
With rs
Me.txttest = !StoreNo


End With

'clean up
rs.Close
Set rs = Nothing
End Sub
 
J

Jeanette Cunningham

Sam,
try this

Sub cboTheComboName_AfterUpdate ()
Dim rs As DAO.Recordset

If Not IsNull(Me.cboTheComboName) Then

'Search in the clone set.
Set rs = Me.RecordsetClone
rs.FindFirst "[KeyID] = " & Me.cboTheComboName
'rs.FindFirst "[KeyID] = """ & Me.cboTheComboName & """" 'text
field

If rs.NoMatch Then
MsgBox "Not found"
Else
'Display the found record in the form.
Me.Bookmark = rs.Bookmark
End If
Set rs = Nothing
End If
End Sub

Jeanette Cunningham

sam said:
Thanks Jeanette, I can do it with that method but want to do it using the
recordset
--
Thanks


Jeanette Cunningham said:
Sam,
try something like this:

If Not IsNull Me.TheComboName Then
With Me.TheComboName
Me.txtboxA = .Column(1)
Me.txtboxB = .Column(2)
End With
End IF


Jeanette Cunningham

sam said:
Hi,
I have an unbound form with a number of combo's. I'm wanting to select
from
the combo and populate a number of text boxes. I know I can do it just
by
putting a control source in the text box of =cboDem.column(2) but am
trying
to work out how to do it with code. I've tried many different ways and
just
can't do it. I think I probably need 'find' in there somewhere... I'm
completely lost now. can anyone assist?




Private Sub cboDemo_AfterUpdate()
Dim rs As DAO.Recordset
Set rs = CurrentDb.OpenRecordset("SELECT tblDemo.DemoIDS,
tblClient.Client, tblStoreDetail.ClientNm, tblStoreDetail.StoreNo FROM
(tblDemo LEFT JOIN tblClient ON tblDemo.ClientID = tblClient.ClentIDS)
LEFT
JOIN tblStoreDetail ON tblDemo.StoreID = tblStoreDetail.StoreIDS WHERE
(((tblDemo.DemoIDS)=[Forms]![tblScheduling]![cboDemo]));")
With rs
Me.txttest = !StoreNo


End With

'clean up
rs.Close
Set rs = Nothing
End Sub
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Similar Threads


Top