We're getting closer. Still getting Run-time error '3061' but
this time it says Expected 1 instead of 2. So we made some
progress there. I made all the changes you suggested. I
appreciate your assistance.
Mark
I really don't know, but let's try a few things to debug this.
Temporarily change the strSQL to
"SELECT * from tblSoxSummaryData " _
& "WHERE Cntrl_num = 'ABC'"
I doubt it will return anything, but see if the error message
goes away. If that gives no error message, it would indicate that
cboCntrl_Num is returning a Null and not a real value.
if it still gives an error message, let's add the supposedly
optional parameter to the OpenRecordset method
Set rs = DB.OpenRecordset(strSQL,dbForwardOnly)
else if it works, change ABC to a real control number and see if
that works.
hth,
Q
Bob, here is my new code. I am getting the following error
however: Run-time error '3061' too few parameters. Expected 2.
This is happening on this line of code:
Set rs = DB.OpenRecordset(strSQL)
A fer possibilities:
Is Cntrl_num actually a text field, not a number?
If it is, then
strSQL = "SELECT * from tblSoxSummaryData WHERE Cntrl_num =
""" _
& cboCntrl_Num & """"
There may be a conflict between adoDb and dao in the type of
recordset created in Access 2000, explicitly declare
Dim rs As dao.Recordset
This is the code in its entirety:
Dim DB As Database
Dim rs As Recordset
Dim strSQL As String
Set DB = CurrentDb
strSQL = "SELECT * from tblSoxSummaryData WHERE Cntrl_num
= " _
& cboCntrl_Num
Set rs = DB.OpenRecordset(strSQL)
Forms!frmSoxSummaryData!Cntrl_Desc = rs!Cntrl_Desc
Forms!frmSoxSummaryData!Process = rs!Process
Forms!frmSoxSummaryData!Sub_Process = rs!Sub_Process
Forms!frmSoxSummaryData!PD = rs!PD
Forms!frmSoxSummaryData!Cntrl_Environ = rs!Cntrl_Environ
Forms!frmSoxSummaryData!Info_Comm = rs!Info_Comm
Forms!frmSoxSummaryData!Monitoring = rs!Monitoring
Forms!frmSoxSummaryData!Risk_Assess = rs!Risk_Assess
Forms!frmSoxSummaryData!Completeness = rs!Completness
Forms!frmSoxSummaryData!Val_Alloc = rs!Val_Alloc
Forms!frmSoxSummaryData!Ext_Occur = rs!Ext_Occur
Forms!frmSoxSummaryData!Rights_Obl = rs!Rights_Obl
Forms!frmSoxSummaryData!Present_Discl = rs!Present_Discl
Forms!frmSoxSummaryData!Res_Access = rs!Res_Access
Forms!frmSoxSummaryData!SOD = rs!SOD
Forms!frmSoxSummaryData!Safe_Assets = rs!Safe_Assets
Forms!frmSoxSummaryData!Anti_Fraud = rs!Anti_Fraud
Forms!frmSoxSummaryData!Cntrl_Type = rs!Cntrl_Type
Set rs = Nothing
Set DB = Nothing
End Sub
Thanks
Bob, thanks for your response. Bear with me as I am not yet
quite an ace programmer but I hope to be. Trust me I love
the cut and paste jobs but I want to understand as well.
Just to confirm, using the code you provided me. Would it
look like this basically. My previous code was working
alright except of course when it came to processing my memo
fields. Your code will work around the 255 char limit I
presume? Thank you!
Mark
yes the code works around the 255 character limit. The code
looks good.
Good luck
Q
would the new code look like this and basically replace what
I have:
Dim DB As Database
Dim rs As Recordset
Dim strSQL as string
Set DB = CurrentDb
strSQL = "SELECT * from tblSoxSummaryData WHERE Cntrl_num
= " _
& cboCntrl_Num
Set rs = DB.OpenRecordset(strSQL)
Forms!frmSoxSummaryData!Cntrl_Desc = rs!Cntrl_Desc
Forms!frmSoxSummaryData!Process = rs!Process
Forms!frmSoxSummaryData!Process = rs!PD
Forms!frmSoxSummaryData!Process = rs!Cntrl_Environ
etc.
Set rs = Nothing
Set DB = Nothing
End Sub
This is the code in its entirety. Not all fields are memo
fields however. Any further coding changes based on this?
I am simply populating different text boxes/fields based
on the query called in the cboCntrl_Num. I will try your
code changes in the meantime. Thanks
Mark
The code below opens a recordset, then populates all the
rows from the combobox, closes the recordset and exits
without using the recordset.
I'd just use the combo box to indicate the selected record,
and then open the recordset already filtered to return the
one row. If your combobox columns are in the same order as
the fields in the table, you could just change the
cboCntrl_Num.Column(n) to refer to the recordset as
rs.fields(n)
a 30 second cut and paste jobbie, if it's the case.
Q
Private Sub cboCntrl_Num_AfterUpdate()
'assigning form field values based on combo box selection
for Control data
Dim DB As Database
Dim rs As Recordset
Set DB = CurrentDb
Set rs = DB.OpenRecordset("tblSoxSummaryData")
Forms!frmSoxSummaryData!Cntrl_Desc =
cboCntrl_Num.Column(1)
Forms!frmSoxSummaryData!Process =
cboCntrl_Num.Column(2)
Forms!frmSoxSummaryData!Sub_Process =
cboCntrl_Num.Column(3) Forms!frmSoxSummaryData!PD =
cboCntrl_Num.Column(4)
Forms!frmSoxSummaryData!Cntrl_Environ =
cboCntrl_Num.Column(5)
Forms!frmSoxSummaryData!Info_Comm =
cboCntrl_Num.Column(6)
Forms!frmSoxSummaryData!Monitoring =
cboCntrl_Num.Column(7)
Forms!frmSoxSummaryData!Risk_Assess =
cboCntrl_Num.Column(8)
Forms!frmSoxSummaryData!Completeness =
cboCntrl_Num.Column(9)
Forms!frmSoxSummaryData!Val_Alloc =
cboCntrl_Num.Column(10)
Forms!frmSoxSummaryData!Ext_Occur =
cboCntrl_Num.Column(11)
Forms!frmSoxSummaryData!Rights_Obl =
cboCntrl_Num.Column(12)
Forms!frmSoxSummaryData!Present_Discl
= cboCntrl_Num.Column(13)
Forms!frmSoxSummaryData!Res_Access
= cboCntrl_Num.Column(14)
Forms!frmSoxSummaryData!SOD =
cboCntrl_Num.Column(15)
Forms!frmSoxSummaryData!Safe_Assets =
cboCntrl_Num.Column(16)
Forms!frmSoxSummaryData!Anti_Fraud =
cboCntrl_Num.Column(17)
Forms!frmSoxSummaryData!Cntrl_Type =
cboCntrl_Num.Column(18)
Set rs = Nothing
Set DB = Nothing
End Sub
Bob Q
--
Posted via a free Usenet account from
http://www.teranews.com
--
Bob Quintal
PA is y I've altered my email address.