Dachande11
Registered User.
- Local time
- Today, 09:31
- Joined
- May 1, 2001
- Messages
- 41
Hello all,
I am trying to find a way of creating a query in code and to pass the result of this query to the variable 'Per_Num'.
I wondered if this could be done using a recordset? I have looked through other topics but am unsure how to use the recordset.
Any help would be much appreciated, I pasted the core bit of the current code below.
Thanks
Private Sub Update_SAC_Click()
Dim cn As ADODB.Connection
Set cn = CurrentProject.Connection
cn.Execute "Delete SAC_SOrg_Temp.Channel, SAC_SOrg_Temp.SAC, SAC_SOrg_Temp.NIV, SAC_SOrg_Temp.Period " & _
"FROM SAC_SOrg_Temp;"
DoCmd.SetWarnings False
DoCmd.OpenQuery "SAC_01", acViewNormal
DoCmd.SetWarnings True
Dim Per_Num As Integer
Per_Num = ???????????
'Period 1 update
If Per_Num >= 1 Then
cn.Execute "UPDATE SAC_Periods INNER JOIN SAC_SOrg_Temp ON SAC_Periods.Channel " & _
"= SAC_SOrg_Temp.Channel SET SAC_Periods.P01 = [niv] " & _
"WHERE SAC_SOrg_Temp.Period='" & "p01' " & ";"
End If
I am trying to find a way of creating a query in code and to pass the result of this query to the variable 'Per_Num'.
I wondered if this could be done using a recordset? I have looked through other topics but am unsure how to use the recordset.
Any help would be much appreciated, I pasted the core bit of the current code below.
Thanks
Private Sub Update_SAC_Click()
Dim cn As ADODB.Connection
Set cn = CurrentProject.Connection
cn.Execute "Delete SAC_SOrg_Temp.Channel, SAC_SOrg_Temp.SAC, SAC_SOrg_Temp.NIV, SAC_SOrg_Temp.Period " & _
"FROM SAC_SOrg_Temp;"
DoCmd.SetWarnings False
DoCmd.OpenQuery "SAC_01", acViewNormal
DoCmd.SetWarnings True
Dim Per_Num As Integer
Per_Num = ???????????
'Period 1 update
If Per_Num >= 1 Then
cn.Execute "UPDATE SAC_Periods INNER JOIN SAC_SOrg_Temp ON SAC_Periods.Channel " & _
"= SAC_SOrg_Temp.Channel SET SAC_Periods.P01 = [niv] " & _
"WHERE SAC_SOrg_Temp.Period='" & "p01' " & ";"
End If