Follow-up question...

  • Thread starter Thread starter Jinsem
  • Start date Start date
J

Jinsem

So I was told how to do what I wanted to know, and well I
almost have it working. My utter lack of knowing what
goes where is playing against me I think. Here is my code
that was told to me, filled in with what I beleive to be
the correct data :

This goes in the text box (source) that will populate off
of a combo box that has data entered into it.

Select [tblMaster_Parts].Item_Desc, [tblMaster_Parts].
[Part_num]
From [tblMaster_Parts]

Now here's the code I was told to use in the combo box to
make the text box populate:

Dim rs As Object
Set rs = Me.RecordsetClone
rs.FindFirst "[tblMaster_Parts].Item_Desc = " & Str(Nz
(Me![Item_Desc_WorkerForm], 0))
If Not rs.EOF Then Me.Bookmark = rs.Bookmark

I entered it straight into the "after updated" line, but
then I got a long macro error saying it didn't have a
macro "me" saved, or entered. So I then addded it as
code, and it doesn't like the third line. I'm hoping I
have the right data, but it's apparent to me from
the "#name" error message in my text box I don't.

Anyone mind attempting to help me ? I figure the only way
to learn is to just keep asking and I will pick it up...

Ahh, before I go... I know my naming is a bit weired, but
I'm trying to learn "[Item_Desc_WorkerForm]" is the name
of the text box I want populated, even though it looks
like a form name.

Jinsem
Who now starts tables with "tbl" and forms with "frm"
 
Close, but it appears you have a few things off a bit. I assume you want to
list all the parts from the tblMaster_Parts in the combobox so that you can
select a part and after you select a part you want to find and display that
parts information in your form.

In the combobox, we'll call it "cboFind" set the following:
Control Source: Leave Blank (this is an unbound control)
Row Source Type: Table/Query
Row Source: Select [tblMaster_Parts].[Item_Desc],
[tblMaster_Parts].[Part_num] From [tblMaster_Parts] ORDER BY
[tblMaster_Parts].[Item_Desc] DESC;

In the After Update event you stated that you entered the code in the code
window and therefore this line should now read [Event Procedure]. Click the
ellipsis(...) to the right of this box to open the VBA editor and enter the
following: (This assumes that the field Item_Desc is included in the
recordset of your form)

Private Sub cboUserID_AfterUpdate()
Dim rs As Object
Dim str As Variant
str = Me.cboFind.Value
Set rs = Me.RecordsetClone
rs.FindFirst [Item_Desc] =" & str
If Not rs.EOF Then Me.Bookmark = rs.Bookmark
End Sub
 
I entered it straight into the "after updated" line, but
then I got a long macro error saying it didn't have a
macro "me" saved, or entered. So I then addded it as
code, and it doesn't like the third line. I'm hoping I
have the right data, but it's apparent to me from
the "#name" error message in my text box I don't.

That is indeed the right code in the wrong place. Instead of putting
the code into the AfterUpdate line, select that event, click the ...
icon, and choose "Code Builder". Access will give you a Sub and End
Sub line, you just edit the code (using your own control and
fieldnames of course). The form property should show [Event
Procedure].
 
Back
Top