retrieving current record in database

Thread Solved

Join Date: Aug 2007
Posts: 32
Reputation: nuBudDy is an unknown quantity at this point 
Solved Threads: 0
nuBudDy nuBudDy is offline Offline
Light Poster

retrieving current record in database

 
0
  #1
Sep 20th, 2007
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
Reply With Quote Quick reply to this message  
Join Date: Jul 2007
Posts: 189
Reputation: plusplus is an unknown quantity at this point 
Solved Threads: 16
plusplus plusplus is offline Offline
Junior Poster

Re: retrieving current record in database

 
0
  #2
Sep 21st, 2007
First of all, why do you have
Visual Basic 4 / 5 / 6 Syntax (Toggle Plain Text)
  1. 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

Visual Basic 4 / 5 / 6 Syntax (Toggle Plain Text)
  1. Receipt.Lbl_Amount.Caption = amount
  2.  
  3. Receipt.Lbl_ReservNo = Adodc1.Recordset.Fields("Reserv_No").Value
  4. Receipt.Lbl_Name.Caption = Adodc1.Recordset.Fields("Cust_Name").Value
  5. Receipt.Lbl_DateOfBooking.Caption = Adodc1.Recordset.Fields("Reserv_Date").Value
  6. Receipt.Lbl_FacType.Caption = Adodc1.Recordset.Fields("Fac_Type").Value
  7. Receipt.Lbl_DateIssued.Caption = Now()
  8. Receipt.Lbl_CurrentUser.Caption = current_user
  9.  
  10. 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
Last edited by plusplus; Sep 21st, 2007 at 1:45 am.
Reply With Quote Quick reply to this message  
Join Date: May 2007
Posts: 537
Reputation: choudhuryshouvi is an unknown quantity at this point 
Solved Threads: 49
choudhuryshouvi's Avatar
choudhuryshouvi choudhuryshouvi is offline Offline
Posting Pro

Re: retrieving current record in database

 
0
  #3
Sep 21st, 2007
use the code in the attachment.
hope it will help you.
Attached Files
File Type: zip Code.zip (5.8 KB, 47 views)
Reply With Quote Quick reply to this message  
Join Date: Aug 2007
Posts: 32
Reputation: nuBudDy is an unknown quantity at this point 
Solved Threads: 0
nuBudDy nuBudDy is offline Offline
Light Poster

Re: retrieving current record in database

 
0
  #4
Sep 21st, 2007
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!
Reply With Quote Quick reply to this message  
Join Date: Jul 2007
Posts: 189
Reputation: plusplus is an unknown quantity at this point 
Solved Threads: 16
plusplus plusplus is offline Offline
Junior Poster

Re: retrieving current record in database

 
0
  #5
Sep 21st, 2007
Did you get your answer or do you still need help
Reply With Quote Quick reply to this message  
Join Date: Jul 2007
Posts: 300
Reputation: jireh is an unknown quantity at this point 
Solved Threads: 42
jireh's Avatar
jireh jireh is offline Offline
Posting Whiz

Re: retrieving current record in database

 
0
  #6
Sep 21st, 2007
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)
  1. with Receipt
  2. .Lbl_Amount.Caption = amounttxt.text
  3. .Lbl_ReservNo = ReservNo.text
  4. .Lbl_Name.Caption = CustName.Text
  5. .Lbl_DateOfBooking.Caption = Now
  6. .Lbl_FacType.Caption = FacType.Text
  7. .Lbl_DateIssued.Caption = Now
  8. .Lbl_CurrentUser.Caption = current_user
  9. .Show
  10. End with
Last edited by jireh; Sep 21st, 2007 at 4:49 am.
Reply With Quote Quick reply to this message  
Join Date: Aug 2007
Posts: 32
Reputation: nuBudDy is an unknown quantity at this point 
Solved Threads: 0
nuBudDy nuBudDy is offline Offline
Light Poster

Re: retrieving current record in database

 
0
  #7
Sep 23rd, 2007
plusplus,i already found the answer.thank you very much 4 ur concern.thanx again.
Reply With Quote Quick reply to this message  
Join Date: Jul 2007
Posts: 189
Reputation: plusplus is an unknown quantity at this point 
Solved Threads: 16
plusplus plusplus is offline Offline
Junior Poster

Re: retrieving current record in database

 
0
  #8
Sep 24th, 2007
If you got your answer then mark the thread solved
Reply With Quote Quick reply to this message  
Join Date: Jul 2007
Posts: 9
Reputation: bapu435 is an unknown quantity at this point 
Solved Threads: 0
bapu435 bapu435 is offline Offline
Newbie Poster

Re: retrieving current record in database

 
0
  #9
Nov 30th, 2007
nuBudDy post your answer here please i want the solution for the same problem but i am not able to ge it thank you
Reply With Quote Quick reply to this message  
Join Date: Aug 2007
Posts: 32
Reputation: nuBudDy is an unknown quantity at this point 
Solved Threads: 0
nuBudDy nuBudDy is offline Offline
Light Poster

Re: retrieving current record in database

 
0
  #10
Dec 22nd, 2007
bapu435, the answer is in the zipfile provided by choudryshouvi
Reply With Quote Quick reply to this message  
Reply

This thread has been marked solved.
Perhaps start a new thread instead?
Message:


Thread Tools Search this Thread



About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC