in vb if in form1 the user login how to come the form2 that come out information with access

Dani AI

Generated

As explained, Form1 is the login screen and Form2 should show that user’s details from an Access database. ’s idea of storing login data in a public module will work for small proofs of concept, but a more robust, maintainable pattern is recommended for real applications.

Authenticate against Access with a parameterized query, then keep only a minimal identifier (UserID) or a small User object in memory. Pass that ID or object into Form2 (constructor or property). Have Form2 load the full details from the database on its Load event so the UI shows the current data. This avoids global state, simplifies testing, and makes the code easier to secure and reason about.

Example flow (VB.NET, OleDb): authenticate and get UserID, then create Form2 with that ID.

' from Form1 after successful authentication
Dim userId As Integer = Authenticate(username, password)
If userId > 0 Then
    Dim frm2 As New Form2(userId)
    frm2.Show()
    Me.Hide()
End If
' Form2 constructor and Load
Public Class Form2
  Private ReadOnly _userId As Integer
  Public Sub New(userId As Integer)
    InitializeComponent()
    _userId = userId
  End Sub
  Private Sub Form2_Load(...) Handles MyBase.Load
    LoadUser(_userId)   ' query DB with parameterized command and populate controls
  End Sub
End Class

Important notes and troubleshooting: use parameterized queries (OleDb uses ? placeholders and parameter order matters), never store plain-text passwords (use salted PBKDF2/Rfc2898 hashing), and ensure the correct Access provider is installed (ACE vs Jet) with matching platform target — set the project to x86 if the 32-bit driver is used. If problems persist, verify the connection string, the Access file path and file lock status, and test the SELECT query directly in Access to confirm results.

Recommended Answers

All 3 Replies

Please be descriptive abut your problem. Do not understand what is your problem. We are here to help you.

oh i mean if the user login then come out the information of the user detail like address, email and more
n i useing VB with the access database and i have two form: in form 1 is the login and form 2 is the information

Declare variables publicly in main module. In Click event of 'ok' button in Form1 store data to the variables and show Form2.
In Form2 Class Module make a sub procedure to show the data of the user from database filtering by the previously declared public variables. Then call the procedure in Form2_Load Event.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.