•
•
•
•
What is DaniWeb IT Discussion Community?
You're currently browsing the Visual Basic 4 / 5 / 6 section within the Software Development category of DaniWeb, a massive community of 456,497 software developers, web developers, Internet marketers, and tech gurus who are all enthusiastic about making contacts, networking, and learning from each other. In fact, there are 2,737 IT professionals currently interacting right now! Registration is free, only takes a minute and lets you enjoy all of the interactive features of the site.
Please support our Visual Basic 4 / 5 / 6 advertiser: Programming Forums
Views: 1788 | Replies: 9 | Solved
![]() |
•
•
Join Date: Aug 2007
Posts: 32
Reputation:
Rep Power: 2
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: 175
Reputation:
Rep Power: 2
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
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
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.ShowAdodc1.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.
•
•
Join Date: Jul 2007
Location: Philippines
Posts: 253
Reputation:
Rep Power: 0
Solved Threads: 28
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:
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.
![]() |
•
•
•
•
•
•
•
•
DaniWeb Visual Basic 4 / 5 / 6 Marketplace
•
•
•
•
Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
- Beginner: how to add new record into database??? (VB.NET)
- retrieving images from database in thumbnail form (PHP)
- Criminal Record Database (Computer Science and Software Design)
- Login and retrieve user data from database (ASP.NET)
- vb6 update record in the database (Visual Basic 4 / 5 / 6)
- 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)
- How to Update a record in a database (PHP)
Other Threads in the Visual Basic 4 / 5 / 6 Forum
- Previous Thread: What is Form in VB6
- Next Thread: resizing toolbar


thanx again.
Linear Mode