User Name Password Register
DaniWeb IT Discussion Community
All
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
Reply
Join Date: Aug 2007
Posts: 32
Reputation: nuBudDy is an unknown quantity at this point 
Rep Power: 2
Solved Threads: 0
nuBudDy nuBudDy is offline Offline
Light Poster

Help retrieving current record in database

  #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
AddThis Social Bookmark Button
Reply With Quote  
Join Date: Jul 2007
Posts: 175
Reputation: plusplus is an unknown quantity at this point 
Rep Power: 2
Solved Threads: 16
plusplus plusplus is offline Offline
Junior Poster

Re: retrieving current record in database

  #2  
Sep 21st, 2007
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
Last edited by plusplus : Sep 21st, 2007 at 1:45 am.
Reply With Quote  
Join Date: May 2007
Location: India
Posts: 501
Reputation: choudhuryshouvi is an unknown quantity at this point 
Rep Power: 3
Solved Threads: 48
choudhuryshouvi's Avatar
choudhuryshouvi choudhuryshouvi is offline Offline
Posting Pro

Solution Re: retrieving current record in database

  #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, 31 views)
Reply With Quote  
Join Date: Aug 2007
Posts: 32
Reputation: nuBudDy is an unknown quantity at this point 
Rep Power: 2
Solved Threads: 0
nuBudDy nuBudDy is offline Offline
Light Poster

Re: retrieving current record in database

  #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  
Join Date: Jul 2007
Posts: 175
Reputation: plusplus is an unknown quantity at this point 
Rep Power: 2
Solved Threads: 16
plusplus plusplus is offline Offline
Junior Poster

Re: retrieving current record in database

  #5  
Sep 21st, 2007
Did you get your answer or do you still need help
Reply With Quote  
Join Date: Jul 2007
Location: Philippines
Posts: 253
Reputation: jireh is an unknown quantity at this point 
Rep Power: 0
Solved Threads: 28
jireh's Avatar
jireh jireh is offline Offline
Posting Whiz in Training

Re: retrieving current record in database

  #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:
     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.
Reply With Quote  
Join Date: Aug 2007
Posts: 32
Reputation: nuBudDy is an unknown quantity at this point 
Rep Power: 2
Solved Threads: 0
nuBudDy nuBudDy is offline Offline
Light Poster

Re: retrieving current record in database

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

Re: retrieving current record in database

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

Re: retrieving current record in database

  #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  
Join Date: Aug 2007
Posts: 32
Reputation: nuBudDy is an unknown quantity at this point 
Rep Power: 2
Solved Threads: 0
nuBudDy nuBudDy is offline Offline
Light Poster

Solution Re: retrieving current record in database

  #10  
Dec 22nd, 2007
bapu435, the answer is in the zipfile provided by choudryshouvi
Reply With Quote  
Reply

Only community members can participate in forum threads. You must register or log in to contribute.

DaniWeb Visual Basic 4 / 5 / 6 Marketplace
Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)

 

Thread Tools Display Modes

Similar Threads
Other Threads in the Visual Basic 4 / 5 / 6 Forum

All times are GMT -4. The time now is 3:29 am.
Forum system based on vBulletin Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
©2003 - 2008 DaniWeb® LLC