can anybody tell me how should save list box data in a mrmasterable.here is the code i have written not working properly
Private Sub Command7_Click()
Dim strReq As String
Dim iTabPos As Integer
If List1.ListIndex >= 0 Then
strReq = List1.Text
iTabPos = InStr(1, strReq, vbTab)
If (iTabPos < 0) Then
MsgBox "Record not found"
Exit Sub
End If
strReq = Left(strReq, iTabPos - 1)
Dim tmpRS As ADODB.Recordset
Set tmpRS = New ADODB.Recordset
Dim StrSql As String
StrSql = "select"
StrSql = StrSql & " * from [Mrmastertable]"
tmpRS.Open _
StrSql, con, adOpenDynamic, adLockOptimistic
If (tmpRS.BOF = True) Or (tmpRS.EOF = True) Then
MsgBox "Record not found"
End If
Exit Sub
'Load the records to ListBox 2
List2.Clear
tmpRS.MoveFirst
Dim strProduct As String, strQty As String, strUnit As String
Do While (Not (tmpRS.EOF))
'write the Data
tmpRS!productname = strProduct
tmpRS!qty = strQty
tmpRS!unit = strUnit
'Add to List box
'Move to Next record
tmpRS.MoveNext
Loop
End If
List2.FontSize = 6
List2.FontBold = True
List2.FontName = "Arial"
End Sub