laysee
asked on
How to Add additional row onto DataGrid
Hi,
Anybody can help! I have probelm to addnew record onto DataGrid, it always overwrite my first record on DataGrid.
I want my form perform in this way:
I key-in the empNo, and the SQL statement will check whether it exist in TransitDB.mdb, if exist the record will be appeared onto DataGrid - it works fine on this part. And update to MasterDB.mdb
But when I key-in the 2nd empNo, the record will overwrite the previous record being called out on the DataGrid. Means, I always get one record appear on DataGrid.
My coding as below:
Private Sub form_load()
Set cn = New ADODB.Connection
Set RS = New ADODB.Recordset
fName = AppendFileToPath(App.Path, "TransitDB.mdb")
f2Name = AppendFileToPath(App.Path, "MasterDB.mdb")
AdoTransDB.ConnectionStrin g = "Provider=Microsoft.Jet.OL EDB.3.51;P ersist Security Info=False;" & _
"Data Source=" & fName
cn.Open AdoTransDB.ConnectionStrin g
End Sub
Private Sub txtempNo_KeyPress(KeyAscii As Integer)
If KeyAscii = vbKeyReturn Then
sqlEmpDet = "SELECT * FROM Emp" & _
" WHERE empid='" & txtempNo & "'"
AdoTransDB.RecordSource = sqlEmpDet
AdoTransDB.Refresh
If txtempNo <> "" Then
If AdoTransDB.Recordset.Recor dCount = 0 Then
MsgBox "Emp# not found!!!"
Else
dbgInvDetail.AllowAddNew = True
AdoTransDB.Refresh
End If
Else
MsgBox "Emp# textbox is blank !!!"
End If
txtempNo.Text = ""
txtempNo.SetFocus
End If
end sub
Anybody can help! I have probelm to addnew record onto DataGrid, it always overwrite my first record on DataGrid.
I want my form perform in this way:
I key-in the empNo, and the SQL statement will check whether it exist in TransitDB.mdb, if exist the record will be appeared onto DataGrid - it works fine on this part. And update to MasterDB.mdb
But when I key-in the 2nd empNo, the record will overwrite the previous record being called out on the DataGrid. Means, I always get one record appear on DataGrid.
My coding as below:
Private Sub form_load()
Set cn = New ADODB.Connection
Set RS = New ADODB.Recordset
fName = AppendFileToPath(App.Path,
f2Name = AppendFileToPath(App.Path,
AdoTransDB.ConnectionStrin
"Data Source=" & fName
cn.Open AdoTransDB.ConnectionStrin
End Sub
Private Sub txtempNo_KeyPress(KeyAscii
If KeyAscii = vbKeyReturn Then
sqlEmpDet = "SELECT * FROM Emp" & _
" WHERE empid='" & txtempNo & "'"
AdoTransDB.RecordSource = sqlEmpDet
AdoTransDB.Refresh
If txtempNo <> "" Then
If AdoTransDB.Recordset.Recor
MsgBox "Emp# not found!!!"
Else
dbgInvDetail.AllowAddNew = True
AdoTransDB.Refresh
End If
Else
MsgBox "Emp# textbox is blank !!!"
End If
txtempNo.Text = ""
txtempNo.SetFocus
End If
end sub
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Hi laysee,
It appears that you have forgotten this question. I will ask Community Support to close it unless you finalize it within 7 days. I will suggest to:
Accept ianouii's comment(s) as an answer.
laysee, if you think your question was not answered at all or if you need help, you can simply post a new comment here. Community Support moderators will followup.
EXPERTS: Please post closing recommendations.
==========
DanRollins -- EE database cleanup volunteer
It appears that you have forgotten this question. I will ask Community Support to close it unless you finalize it within 7 days. I will suggest to:
Accept ianouii's comment(s) as an answer.
laysee, if you think your question was not answered at all or if you need help, you can simply post a new comment here. Community Support moderators will followup.
EXPERTS: Please post closing recommendations.
==========
DanRollins -- EE database cleanup volunteer
shall share the points among us, ok?
Recommendation:
Split points between ianouii and gron
DanRollins -- EE database cleanup volunteer
Split points between ianouii and gron
DanRollins -- EE database cleanup volunteer
thanks.
Per recommendation, force-accepted.
Netminder
CS Moderator
ianouii: points for you at https://www.experts-exchange.com/jsp/qShow.jsp?ta=visualbasic&qid=20317591
Netminder
CS Moderator
ianouii: points for you at https://www.experts-exchange.com/jsp/qShow.jsp?ta=visualbasic&qid=20317591
If txtempNo <> "" Then
If AdoTransDB.Recordset.Recor
MsgBox "Emp# not found!!!"
Else
dbgInvDetail.AllowAddNew = True
AdoTrannsDB.HoldFields
AdoTransDB.Refresh
End If
Else
MsgBox "Emp# textbox is blank !!!"
End If
good luck.