i have declare variabel for connection, recordset and connection string in module and make procedure for initialize database but the variabels aren't recognize in form.
so now if i have 5 forms then i must declare the variabels 5 times.
here are my code :
VB Code:
'in module Public Sub init_database() Dim con As ADODB.Connection Dim rs As ADODB.Recordset Dim constring As String Set con = New ADODB.Connection Set rs = New ADODB.Recordset constring = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & App.Path & "\toko.mdb;Mode=ReadWrite;Persist Security Info=False" con.Open constring End Sub 'in form Private Sub txt_departemen_LostFocus() Call init_database rs.Open "select * from stock", con, adOpenKeyset, adLockReadOnly End Sub
the error message appear is "variabel not defined" for object con.
thanks in advance for your help![]()




Reply With Quote