Hi peko,
I have tried your solution but i get an error with the recordst. This is how i implemented the code.
For the form with the listview items i added:-
Code:
Private Sub ListView1_DblClick()
Dim strSQL As String
Dim UserId As String
UserId = Me.ListView1.SelectedItem.Text
frmUser.UserId = UserNo
frmUser.Show vbModal
End Sub
And for the details table i added:-
Code:
Dim cn As ADODB.Connection
Dim rs As ADODB.Recordset
Private mstrID As String
Public Property Let UserId(ByVal NewUserId As String)
mstrID = UserId
End Property
Public Property Get UserId() As String
UserId = mstrID
End Property
Private Sub Form_Load()
Dim strSQL As String
Set cn = New ADODB.Connection
cn.Provider = "Microsoft.Jet.OLEDB.4.0"
cn.Open App.Path & "./databases/Visualtek.mdb"
Set rs = New ADODB.Recordset
strSQL = "SELECT * FROM users WHERE UserId = " & mstrID
rs.Open strSQL, cn, adOpenDynamic
txtLastName.Text = rs.Fields("LastName").Value
txtFirstName.Text = rs.Fields("FirstName").Value
rs.Close
Set rs = Nothing
End Sub
The error given is "No value given for one or more parameters"
When I debug the code it pints at the rs.Open line and shows the sql to be:
strSQL = "SELECT * FROM users WHERE UserId = john"
Yet UserId should be picking the UserID field but in this case it is picking the LastName field. Where am I going wrong?
I will really appreciate your help.
Thanks