Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Update in the middle of a code

Status
Not open for further replies.

Krash878

Programmer
May 8, 2001
172
US
I need to have my Form update so it can list the next series of code. I do not know what the command to update is. Here is the code:

Private Sub CloseCB_Click()

Me.DateClosed = Date
Me.IsClosed = 1
-----------Update Code here------------

Dim MyDB As Database
Dim Rec As Recordset
Dim SQLString As String

SQLString = "SELECT tblChargeBack.StartDate, tblChargeBack.SequenceNumber, tblChargeBack.Amount, tblChargeBack.DateClosed, DateDiff('d',[StartDate],[DateClosed]) AS Elapsed, (IIf([Elapsed]=0,1,[Elapsed])*(0.06/365)*[Amount]*0.01) AS Interest FROM tblChargeBack"
Set MyDB = CurrentDb()
Set Rec = MyDB.OpenRecordset(SQLString, dbOpenSnapshot)
Me.InterestFee = Rec!Interest
End Sub

Thanks

Kenny
 
I am real confused by the code above. If you are setting the value of one field on your form there is no need to retrieve all the other fields into the recordset.
if you are trying to add the rest of the fields to your from then just continue on
me.chargedate = rec!chargedate
me.seqnum = rec!seqnumber etc...

but I would suggest you try
Dim SQLString As String

SQLString = "SELECT tblChargeBack.StartDate, tblChargeBack.SequenceNumber, tblChargeBack.Amount, tblChargeBack.DateClosed, DateDiff('d',[StartDate],[DateClosed]) AS Elapsed, (IIf([Elapsed]=0,1,[Elapsed])*(0.06/365)*[Amount]*0.01) AS Interest FROM tblChargeBack"
Set MyDB = CurrentDb()
Set Rec = MyDB.OpenRecordset(SQLString, dbOpenSnapshot)
me.formname.recordsource = sqlstring

if you are just trying to loop to the next record then
just rec.movenext is the command but you will need

rec.movefirst
do until rec.eof
Me.InterestFee = Rec!Interest
rec.movenext
loop
Good luck
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top