
Originally Posted by
ranman256
Depends...
1. What is stLinkCriteria set to? try only: DoCmd.OpenForm stDocName
2. What is VSet!RS_CONTAINER2_CODE set to?
It could fail depending on what Vset is.
You can use
Set rc_code_set = CurrentDb.OpenRecordset("Select * from lov_rs_containers where rc_name1='" & CStr(VSet!RS_CONTAINER2_CODE) & "'")
ok heres the code.
if i open the 1 button
this is the code
Code:
Private Sub BCharter_Click()'On Error GoTo Err_BCharter_Click
Dim stDocName As String
Dim stLinkCriteria As String
stDocName = "Charters"
DoCmd.OpenForm stDocName, , , stLinkCriteria " (this is the first one) Charters is the name of one in 7 tables"
Exit_BCharter_Click:
Exit Sub
'Err_BCharter_Click:
' MsgBox Err.Description
' Resume Exit_BCharter_Click
End Sub
and this is the second
Code:
Sub updatetable()
Dim Ret As String, VSet As Recordset
Set VSet = CurrentDb().OpenRecordset("Select distinct RS_CONTAINER2_CODE from realestates ")
Dim SQL As String
Dim rc_code_set As Recordset
Do Until VSet.EOF
Set rc_code_set = CurrentDb().OpenRecordset("Select * from lov_rs_containers where rc_name1='" & CStr(VSet!RS_CONTAINER2_CODE) & "'")
SQL = "UPDATE realestates " & _
" SET realestates.rs_container1_code = " & _
rc_code_set!RC_Code & " WHERE realestates.rs_container2_code =" _
& VSet!RS_CONTAINER2_CODE
DoCmd.RunSQL SQL
rc_code_set.Close
VSet.MoveNext
Loop
VSet.Close
End Sub