afternoon all,
hopefully, someone can point me in the best dircetion to do this in vba.
i have a form with numerous text fields - most have their control source as a record set passed from a query. there are a few, however, that are unbound. these need to be updated / changed / etc based upon different apsects of the record set or calcutlations based on the record set.
what i'm atempting to do is use vba to update these text fields on the on open event. the form is a continous form that can vary from 2 entries (records) to theoretically an infinate number of entries.
what i have so far:
i am having trouble setting the field [Net_Due] to contain the appropriate data. the messagebox that shows n_due shows that n_due contains the correct data - but no matter what i do the field [Net_Due] does not show the correct data. seems to only show the first instance of n_due or the last instance (based upon how i change my code). probably missing something simple here - do i need to make n_due an array and then somehow loop through the form - setting each instance of [Net_Due]?
hope this makes sense.
any suggestions appreciated.
i've already been down the road trying to use calculated fields in the query and am not able to accomplish what is needed here there. i cannot change any thing in the underlying tables nor add new ones.
thanks in advance.
regards,
longhair
hopefully, someone can point me in the best dircetion to do this in vba.
i have a form with numerous text fields - most have their control source as a record set passed from a query. there are a few, however, that are unbound. these need to be updated / changed / etc based upon different apsects of the record set or calcutlations based on the record set.
what i'm atempting to do is use vba to update these text fields on the on open event. the form is a continous form that can vary from 2 entries (records) to theoretically an infinate number of entries.
what i have so far:
Code:
Private Sub Form_Open(Cancel As Integer)
Dim dbs As DAO.Database
Dim intRecCount1 As Integer
rstPostDtl.MoveLast
rstPostDtl.MoveFirst
Set dbs = CurrentDb
Set Forms("VendDtl2").Recordset = rstPostDtl
Me.Text0 = txtVend
Me.Text2 = txtName
intRecCount1 = rstPostDtl.RecordCount
n_due = 0
With rstPostDtl
Do While Not rstPostDtl.EOF
For i = 1 To intRecCount1
If .Fields(0) = "V" Then
n_due = .Fields(6)
Else: n_due = n_due + .Fields(5)
End If
'Me.Net_Due.Value = n_due <-issue is here?
MsgBox (n_due)
.MoveNext
Next i
Loop
End With
End Sub
hope this makes sense.
any suggestions appreciated.
i've already been down the road trying to use calculated fields in the query and am not able to accomplish what is needed here there. i cannot change any thing in the underlying tables nor add new ones.
thanks in advance.
regards,
longhair