Here's what I have...
Private Sub cmdRevGoal_Click()
On Error GoTo Err_cmdRevGoal_Click
Dim strDocName As String
Dim stLinkCriteria As String
Dim strSQL As String
Dim strWhere As String
strDocName = "frmRBES1"
'strWhere = "txtStaffMember = """ & Me.cboName & """"
'strSQL = "SELECT txtGoal,
txtRationale,txtSchoolRenewArea,txtBaseData,txtIndOfSuccess,txtMeasMeth,txtImpPlan,txtTimeLine FROM RBES1 " _
'& "WHERE [txtStaffMember] = """ & Me.cboName & """"
DoCmd.OpenForm "frmRBES1", , , strWhere
'DoCmd.OpenTable "RBES1"
'Me.SetFocus
'Forms!frmRBES1.RecordSource = strSQL
Forms!frmRBES1.txtRB1_StaffMem = cboName
'Forms!frmRBES1.[txtRB1_Goal] = RBES1.txtGoal
Forms!frmRBES1.txtRationale = ?
Forms!frmRBES1.txtSchoolRenewArea = ?
Forms!frmRBES1.txtBaseData = ?
Forms!frmRBES1.txtIndOfSuccess = ?
Forms!frmRBES1.txtMeasMeth = ?
Forms!frmRBES1.txtImpPlan = ?
Forms!frmRBES1.txtTimeLine = ?
Exit_cmdRevGoal_Click:
Exit Sub
Err_cmdRevGoal_Click:
MsgBox Err.Description
Resume Exit_cmdRevGoal_Click
End Sub
The lines that are commented out are attempts that I made with your earlier
suggestions. The only thing that does work is the line that opens the form
and the line that puts the name from the combo box into the respective text
box on the form (Forms!frmRBES1.txtRB1_StaffMem = cboName). I want to take
the remaining fields from the record that has the particular
txtRBES1_StaffMem and put them in the other text boxes on the form
(Forms!frmRBES1.txtRationale ,...etc.). The records are contained in a table
named RBES1. I had tried that with the lines that end with a question mark.
Am I way out in outer space with my thinking on this?
Marshall Barton said:
Do you have any code for the button? The button wizard will
generate most of it for you. Once you have that, modify it
to include what I posted. If you can't figure out to make
the changes, at least post a Copy/Paste of the code that you
do have.
You have created to other form, right? The form has a table
or a query as its record source, right? Basically, if you
open the form from that database window, it should show you
all the records in the tabe/query. When you open it using
the button's Click event code, it should filter the records
to the one with the selected name.
If that's still not enough to get you going, it would help
if you provided more details about the form, the combo box
and the table/query.
--
Marsh
MVP [MS Access]
Sorry, but this didn't help. Perhaps I just don't understand Access well
enough.. I want to do this... 1. Pick a name from a combo box 2. Click a
command button - the command button will use the name from the combo box to
load the record which has the same name in one of it's fields (I made it a
key field) in a particular table into a particular form. I'm sorry, but I'm
just not clear as to how to code the button to grab all the other fields from
this record as well as the one with the same name as the combo box and put
them into the form
Marshall Barton said:
Ok. For this question (as opposed to your original
question), I recommend that you use the OpenForm method's
WhereCondition argument. Still assuming that the keyfield is
a Text type field, the button's Click event procedure would
include code something like this:
Dim strWhere As String
strWhere = "[namefield] = """ & Me.combo & """"
DoCmd.OpenForm "nameofform", , , strWhere