Home > Software engineering >  Just learning the ACCESS, process, using VB to add event is always an error
Just learning the ACCESS, process, using VB to add event is always an error

Time:10-05

I recently made a salary access2010 database, add "become the" event process, using VB compiled code is always a compiler is not successful,
Objects displayed runtime error 3704 closing, operation is not allowed!!!! Ask ace to give advice or comments!!!!!
-- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
Private Sub Fillbtns ()
'show in the table of switch box
'display button
Const connumbottons As Integer=8
Dim the rs As New ADODB. You
Dim STRSQL As String
Dim intbtn As Integer
The Me! [r]. Btn1 SetFocus
For intbtn=2 To connumbuttons
Me (" BTN "& amp; Intbtn). The Visible=False
Me (" LBL "& amp; Intbtn). The Visible=False
Next intbtn
'open the table Switchboard Items
STRSQL="SELECT * FROM [Switchboard Items]"
STRSQL=STRSQL & amp; "WHERE [ItemNumber] & gt; 0 AND [SwitchboardID]="& amp; The Me! [SwitchboardID]
STRSQL=STRSQL & amp; "The ORDER BY [ItemNumber]."
Set the rs=Getrs (STRSQL)
If (EOF) rs. Then
The Me! [lbl1]. Caption="this switch panel without project" on page
The Else
While (Not (EOF) rs.)
Me (" BTN "& amp; Rs! [ItemNumber]). The Visible=True
Me (" LBL "& amp; Rs! [ItemNumber]). The Visible=True
Me (" LBL "& amp; Rs! [ItemNumber]). The Caption=rs! [ItemText]
Rs. MoveNext
Wend
End the If
'close the data collection and database
Rs. Close
Set the rs=Nothing
End Sub
------------------------------------------------------------------------------------------

CodePudding user response:

Getrs how to write?
Is there to Open the Connection (Connection. The Open)? Is there a closed the connection in advance?

CodePudding user response:

The instructions for not establish the connection with database

CodePudding user response:

The Public Function Getrs (ByVal Strquery As String) As the ADODB library you
Dim the rs As New ADODB. You
Dim conn As New ADODB. Connection
On Error GoTo getrs_error
Set the conn=CurrentProject. Connection
Rs. The Open Strquery, conn, adopenkeyset, adLockOptimistic
The Set Getrs=rs
Getrs_exit:
Set the rs=Nothing
Set the conn=Nothing
The Exit Function
Getrs_error:
MsgBox (Err. Description)
Resume getrs_exit
End the Function
-- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
This is the code Getrs,,,