Results 1 to 4 of 4

Thread: [RESOLVED]have declare variable in module but cant recognize in form

Threaded View

  1. #1

    Thread Starter
    Member
    Join Date
    Jul 2005
    Posts
    33

    Resolved [RESOLVED]have declare variable in module but cant recognize in form

    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:
    1. 'in module
    2. Public Sub init_database()
    3. Dim con As ADODB.Connection
    4. Dim rs As ADODB.Recordset
    5. Dim constring As String
    6. Set con = New ADODB.Connection
    7. Set rs = New ADODB.Recordset
    8. constring = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & App.Path & "\toko.mdb;Mode=ReadWrite;Persist Security Info=False"
    9. con.Open constring
    10. End Sub
    11.  
    12. 'in form
    13. Private Sub txt_departemen_LostFocus()
    14.         Call init_database
    15.         rs.Open "select * from stock", con, adOpenKeyset, adLockReadOnly
    16. End Sub

    the error message appear is "variabel not defined" for object con.

    thanks in advance for your help
    Last edited by little_mouse; Jul 20th, 2005 at 09:12 AM. Reason: resolve

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width