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 Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Code Problem

Status
Not open for further replies.

anon47

Programmer
Nov 28, 2006
80
US
The code below gives no error. But it don't update the record like it is designed to? Any help I have used this type of code before adn its worked great.


Set rst = CurrentDb.OpenRecordset("SELECT * FROM [CreditFile] Where [CreditFile].[ProjectID]=" & Me.[ProjectID])
If Not IsNull(rst.[ProjectID]) Then
rst.Edit
rst![LastPaymentDate].Value = Me.PaymentDate ' Text Field
rst![LastPaymentAmount].Value = Me.PaymentAmount " Text Field
rst![CurrentBalance].Value = Me.BalanceDue 'Text Field
rst.Update
rst.Close
End If
 





hi,

"...But it don't update the record like it is designed to?..."

What is the intent?

What is ACTUALLY happening that is NOT the intent?

Skip,
[sub]
[glasses] When a group touring the Crest Toothpaste factory got caught in a large cooler, headlines read...
Tooth Company Freeze a Crowd! and
Many are Cold, but Few are Frozen![tongue][/sub]
 
Its not editing the information when the code is ran on click. I am baffled and have been running the code in multi configs to see if it was maybe a field issue but nothing works.
 
It is designed to open the recorded and find the one that matches the id then change the value you as indecated. Thanks
 




Does the Select return the row you are looking for?

Skip,
[sub]
[glasses] When a group touring the Crest Toothpaste factory got caught in a large cooler, headlines read...
Tooth Company Freeze a Crowd! and
Many are Cold, but Few are Frozen![tongue][/sub]
 

If you copied your code correctly, change this...
Code:
rst![LastPaymentAmount].Value = Me.PaymentAmount " Text Field
to this...
Code:
rst![LastPaymentAmount].Value = Me.PaymentAmount [COLOR=red]'[/color] Text Field

Randy
 
Is [CreditFile].[ProjectID] defined as a numeric field, or text? If text, change:

Set rst = CurrentDb.OpenRecordset("SELECT * FROM [CreditFile] Where [CreditFile].[ProjectID]=" & Me.[ProjectID])

to

Set rst = CurrentDb.OpenRecordset("SELECT * FROM [CreditFile] Where [CreditFile].[ProjectID]=""" & Me.[ProjectID]) &
 
Correction:

Change it to:

Set rst = CurrentDb.OpenRecordset("SELECT * FROM [CreditFile] Where [CreditFile].[ProjectID]=""" & Me.[ProjectID] & """)
 
How are ya anon47 . . .

. . . and this:
Code:
[blue]   Dim db As DAO.Recordset, rst As DAO.Recordset, SQL As String
   Dim Msg As String, Style As Integer, Title As String

   Set db = CurrentDb
   SQL = "SELECT * " & _
         "FROM CreditFile " & _
         "Where (ProjectID = " & Me.ProjectID & ");"
   Set rst = db.OpenRecordset(SQL, dbOpenDynaset)
   
   If rst.BOF Then
      Msg = "Record not found matching ProjectID " & Me!ProjectID & "!"
      Style = vbInformation + vbOKOnly
      Title = "Can't Find Record! . . ."
      MsgBox Msg, Style, Title
   Else
      With rst
         .Edit
         !LastPaymentDate = Me.PaymentDate
         !LastPaymentAmount = Me.PaymentAmount
         !CurrentBalance = Me.BalanceDue
         .Update
      End With
   End If
   
   Set rst = Nothing
   Set db = Nothing[/blue]

Calvin.gif
See Ya! . . . . . .

Be sure to see FAQ219-2884:
 
Thanks guys Project ID is a num field
 
Ok guys this is what works thanks again

Set rst = CurrentDb.OpenRecordset("SELECT * FROM [CreditFile] Where [CreditFile].[ProjectID]=" & Me.[ProjectID])
If rst.BOF Then
End
Else
rst.Edit
rst![LastPaymentDate].Value = Me.PaymentDate
rst![LastPaymentAmount].Value = Me.PaymentAmount
rst![CurrentBalance].Value = Me.BalanceDue
rst.Update
rst.Close
End If
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top