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 :

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

Edited 3 Years Ago by mike_2000_17: Fixed formatting

First of all, why do you have

unload me

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

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

and you don't need

Adodc1.RecordSource = (current record that has just been added)//i don't know how!
Adodc1.Recordset.Requery
Adodc1.Refresh

plusplus, thank you for your effort to help.does it really point to the current record because it didn't seem to work.maybe there is an error in other parts of the codes..

n choudhuryshouvi,thank you very much for your help,it worked well!

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

plusplus,i already found the answer.thank you very much 4 ur concern.;)thanx again.

nuBudDy post your answer here please i want the solution for the same problem but i am not able to ge it thank you

bapu435, the answer is in the zipfile provided by choudryshouvi

This question has already been answered. Start a new discussion instead.