| | |
retrieving current record in database
Thread Solved |
•
•
Join Date: Aug 2007
Posts: 32
Reputation:
Solved Threads: 0
hello, i neeed help badly.my problem is i want to retrieve the record that has just been added.
let say:
step :load RESERVATION form->fill in details->click the save button->load RECEIPT form
as soon as i click the save button, i want the records to be displayed in RECEIPT form.
all this operation happens in a single click.but i dont know how to retrieve it!please help.here is my codings :
[code]
With Adodc1
.Refresh
.Recordset.AddNew
.Recordset.Fields("Cust_Contact") = Txt_Contact.Text
.Recordset.Fields("Fac_Type") = Fac_type
.Recordset.Fields("Reserv_Date") = Now()
.Recordset.Fields("Booking_Time") = time
.Recordset.Fields("Cust_Name") = Txt_Name.Text
.Recordset.Update
MsgBox "Records have been successfully saved!", vbOKOnly
End With
End If
End If
Unload Me
Adodc1.RecordSource = (current record that has just been added)//i don't know how!
Adodc1.Recordset.Requery
Adodc1.Refresh
Receipt.Lbl_Amount.Caption = amount
Receipt.Lbl_ReservNo = Adodc1.Recordset.Fields("Reserv_No").Value
Receipt.Lbl_Name.Caption = Adodc1.Recordset.Fields("Cust_Name").Value
Receipt.Lbl_DateOfBooking.Caption = Adodc1.Recordset.Fields("Reserv_Date").Value
Receipt.Lbl_FacType.Caption = Adodc1.Recordset.Fields("Fac_Type").Value
Receipt.Lbl_DateIssued.Caption = Now()
Receipt.Lbl_CurrentUser.Caption = current_user
Receipt.Show
End Sub
let say:
step :load RESERVATION form->fill in details->click the save button->load RECEIPT form
as soon as i click the save button, i want the records to be displayed in RECEIPT form.
all this operation happens in a single click.but i dont know how to retrieve it!please help.here is my codings :
[code]
With Adodc1
.Refresh
.Recordset.AddNew
.Recordset.Fields("Cust_Contact") = Txt_Contact.Text
.Recordset.Fields("Fac_Type") = Fac_type
.Recordset.Fields("Reserv_Date") = Now()
.Recordset.Fields("Booking_Time") = time
.Recordset.Fields("Cust_Name") = Txt_Name.Text
.Recordset.Update
MsgBox "Records have been successfully saved!", vbOKOnly
End With
End If
End If
Unload Me
Adodc1.RecordSource = (current record that has just been added)//i don't know how!
Adodc1.Recordset.Requery
Adodc1.Refresh
Receipt.Lbl_Amount.Caption = amount
Receipt.Lbl_ReservNo = Adodc1.Recordset.Fields("Reserv_No").Value
Receipt.Lbl_Name.Caption = Adodc1.Recordset.Fields("Cust_Name").Value
Receipt.Lbl_DateOfBooking.Caption = Adodc1.Recordset.Fields("Reserv_Date").Value
Receipt.Lbl_FacType.Caption = Adodc1.Recordset.Fields("Fac_Type").Value
Receipt.Lbl_DateIssued.Caption = Now()
Receipt.Lbl_CurrentUser.Caption = current_user
Receipt.Show
End Sub
•
•
Join Date: Jul 2007
Posts: 189
Reputation:
Solved Threads: 16
First of all, why do you have
in the middle of your sub? The program won't do the lines after that.
And now to your question, when you just added a record, then your recordset is pointing to that record so you can just do
and you don't need
Adodc1.RecordSource = (current record that has just been added)//i don't know how!
Adodc1.Recordset.Requery
Adodc1.Refresh
Visual Basic 4 / 5 / 6 Syntax (Toggle Plain Text)
unload me
And now to your question, when you just added a record, then your recordset is pointing to that record so you can just do
Visual Basic 4 / 5 / 6 Syntax (Toggle Plain Text)
Receipt.Lbl_Amount.Caption = amount Receipt.Lbl_ReservNo = Adodc1.Recordset.Fields("Reserv_No").Value Receipt.Lbl_Name.Caption = Adodc1.Recordset.Fields("Cust_Name").Value Receipt.Lbl_DateOfBooking.Caption = Adodc1.Recordset.Fields("Reserv_Date").Value Receipt.Lbl_FacType.Caption = Adodc1.Recordset.Fields("Fac_Type").Value Receipt.Lbl_DateIssued.Caption = Now() Receipt.Lbl_CurrentUser.Caption = current_user Receipt.Show
Adodc1.RecordSource = (current record that has just been added)//i don't know how!
Adodc1.Recordset.Requery
Adodc1.Refresh
Last edited by plusplus; Sep 21st, 2007 at 1:45 am.
another suggestion, inestead of getting a record from the database why dont you use the data from the textboxes or from the variables you have used to add? example:
Visual Basic 4 / 5 / 6 Syntax (Toggle Plain Text)
with Receipt .Lbl_Amount.Caption = amounttxt.text .Lbl_ReservNo = ReservNo.text .Lbl_Name.Caption = CustName.Text .Lbl_DateOfBooking.Caption = Now .Lbl_FacType.Caption = FacType.Text .Lbl_DateIssued.Caption = Now .Lbl_CurrentUser.Caption = current_user .Show End with
Last edited by jireh; Sep 21st, 2007 at 4:49 am.
A conclusion is the place where you got tired of thinking. http://www.martin2k.co.uk/forums/index.php?showforum=4
http://www.a1vbcode.com/a1vbcode/vbforums/Forum3-1.aspx
http://www.developerfusion.co.uk/for...orum&ForumID=4
![]() |
Similar Threads
- How to Update a record in a database (PHP)
- vb6 update record in the database (Visual Basic 4 / 5 / 6)
- Beginner: how to add new record into database??? (VB.NET)
- retrieving images from database in thumbnail form (PHP)
- Criminal Record Database (Computer Science)
- Login and retrieve user data from database (ASP.NET)
- link record in database with contactItem? (Visual Basic 4 / 5 / 6)
- gwt the record which match the current date (Visual Basic 4 / 5 / 6)
- how willl i be able to save a specific record into my database file in ms access (Java)
Other Threads in the Visual Basic 4 / 5 / 6 Forum
- Previous Thread: What is Form in VB6
- Next Thread: resizing toolbar
| Thread Tools | Search this Thread |
* 6 429 2007 access activex add age application basic beginner birth bmp calculator cd cells.find click client code college component connection connectionproblemusingvb6usingoledb copy creat ctrl+f data database datareport date delete dissertations dissertationthesis dissertationtopic edit error excel excelmacro file filename form hardware header iamthwee image inboxinvb internetfiledownload keypress label listbox listview liveperson login looping machine microsoft movingranges number objectinsert open oracle password prime program prompt range-objects readfile reading record refresh remotesqlserverdatabase report save search sendbyte sites sort sql sql2008 sqlserver subroutine tags textbox time urldownloadtofile vb vb6 vb6.0 vba visual visualbasic visualbasic6 web window windows





thanx again. 