- Local time
- Today, 23:26
- Joined
- Sep 28, 2010
- Messages
- 83
Morning folks, hope Access is being kind to you today..
I'm mid build on a commitments tracking (pseudo Purchase Order system) project, but seem to have run into an issue with a loop I'm building to allow users to edit commitments.
The idea is that an edit form is launched, values amended and the submit button is clicked. A VB subroutine then validates the entries to ensure that the mandatory entries are included. It then writes a copy of the original values to the Archive table, before attempting to update the existing commitment with the new values..
This is working perfectly, apart from the fact that 3 fields that are "updated" are being updated to a blank value..
Code is thus :
The Query being called is as follows..
and the three fields which are not being updated/nulled out are tblcommitments.Type
tblcommitments.Owner
& tblcommitments.Heading
tl/dr - Some fields in a VB called update query are not updating...
Anyone have any thoughts on what I've done wrong here?
Feel free to shout up if I've missed any information..
Cheers..
slinky
I'm mid build on a commitments tracking (pseudo Purchase Order system) project, but seem to have run into an issue with a loop I'm building to allow users to edit commitments.
The idea is that an edit form is launched, values amended and the submit button is clicked. A VB subroutine then validates the entries to ensure that the mandatory entries are included. It then writes a copy of the original values to the Archive table, before attempting to update the existing commitment with the new values..
This is working perfectly, apart from the fact that 3 fields that are "updated" are being updated to a blank value..
Code is thus :
Code:
Private Sub CommitSubmit_Click()
Dim SQLStr, LastID, DOwner, DHeading As String
Dim ErrState, Dtype, DProperty, DTCA, DITD, DSD, DED, DSP, DRetention, DRA, DRPD, DSupplier, DDOW, DStatus, DUser, DShD As String
Dim Authcheck, Complete, ErrMsg As Boolean
Dim QDF1, QDF2 As QueryDef
Dtype = Me.Type.Value
DHeading = Nz(Me.Heading.Value)
DProperty = Me.Property.Value
DTCA = Me.TCA.Value
DITD = Me.ITD.Value
DSD = Me.SD.Value
DED = Me.ED.Value
DSP = Me.SP.Value
DRetention = Me.Retention.Value
DRA = Me.RA.Value
DRPD = Me.RPD.Value
DSupplier = Me.Supplier.Value
DShD = Nz(Me.ShortDescription.Value)
DDOW = Me.DOW.Value
DStatus = Me.Status.Value
DUser = UCase(Environ("Username"))
DOwner = Nz(Me.Owner.Value)
Authcheck = Nz(DLookup("Authlimit", "tblstaff", "Userid='" & Environ("username") & "'") > DTCA)
ErrState = 0
If IsNull(Dtype) Then ErrState = ErrState + 1
If DHeading = "" Then ErrState = ErrState + 1
If IsNull(DProperty) Then ErrState = ErrState + 1
If IsNull(DTCA) Then ErrState = ErrState + 1
If IsNull(DSD) Then ErrState = ErrState + 1
If DRetention = -1 Then
If IsNull(DRPD) Then ErrState = ErrState + 1
If IsNull(DRA) Then ErrState = ErrState + 1
End If
If IsNull(DShD) Then ErrState = ErrState + 1
If IsNull(DSupplier) Then ErrState = ErrState + 1
If IsNull(DStatus) Then ErrState = ErrState + 1
If DOwner = "" Then ErrState = ErrState + 1
If IsNull(Dtype) Then Me.Type.BackColor = vbRed
If DHeading = "" Then Me.Heading.BackColor = vbRed
If IsNull(DProperty) Then Me.Property.BackColor = vbRed
If IsNull(DTCA) Then TCA.BackColor = vbRed
If IsNull(DSD) Then SD.BackColor = vbRed
If DRetention = -1 Then
If IsNull(DRPD) Then RPD.BackColor = vbRed
If IsNull(DRA) Then RA.BackColor = vbRed
End If
If IsNull(DShD) Then ShortDescription.BackColor = vbRed
If IsNull(DSupplier) Then Supplier.BackColor = vbRed
If IsNull(DStatus) Then Status.BackColor = vbRed
If DOwner = "" Then Owner.BackColor = vbRed
If Not ErrState <> 0 Then
Set db = CurrentDb
Set qdf = db.QueryDefs("qry-AppendArchive")
qdf.Parameters(0) = Eval(Forms![frmcommitmentedit]![CommID])
qdf.Execute dbFailOnError
Set qdf = db.QueryDefs("qry_UpdateCommitment")
qdf.Parameters(0) = Eval(Forms![frmcommitmentedit]![CommID])
qdf.Parameters(1) = DLookup("version", "tblcommitments", "ID=" & Forms![frmcommitmentedit]![CommID]) + 1
qdf.Parameters(2) = Forms![frmcommitmentedit]![Type]
qdf.Parameters(3) = Forms![frmcommitmentedit]![Property]
qdf.Parameters(4) = Eval(Forms![frmcommitmentedit]![TCA])
qdf.Parameters(5) = Nz(Forms![frmcommitmentedit]![ITD], 0)
qdf.Parameters(6) = Forms![frmcommitmentedit]![SD]
qdf.Parameters(7) = Forms![frmcommitmentedit]![ED]
qdf.Parameters(8) = Forms![frmcommitmentedit]![SP]
qdf.Parameters(9) = Eval(Forms![frmcommitmentedit]![Retention])
qdf.Parameters(10) = Forms![frmcommitmentedit]![RPD]
qdf.Parameters(11) = Forms![frmcommitmentedit]![RA]
qdf.Parameters(12) = Forms![frmcommitmentedit]![Supplier]
qdf.Parameters(13) = Forms![frmcommitmentedit]![ShortDescription]
qdf.Parameters(14) = Forms![frmcommitmentedit]![DOW]
qdf.Parameters(15) = Forms![frmcommitmentedit]![Status]
qdf.Parameters(16) = Forms![frmcommitmentedit]![Owner]
qdf.Parameters(17) = Forms![frmcommitmentedit]![Heading]
qdf.Parameters(18) = Forms![frmcommitmentedit]![pCommit]
qdf.Parameters(19) = UserName()
qdf.Execute dbFailOnError
Else
ErrMsg = MsgBox("Some required elements are incomplete, please ensure all necessary data is entered. " & ErrState & " items are missing.", vbInformation)
End If
End Sub
The Query being called is as follows..
Code:
PARAMETERS [Param-CommID] IEEEDouble, [Param-Version] IEEESingle, [Param-Type] Text ( 255 ), [Param-Property] Text ( 255 ), [Param-TotalContractAmount] Text ( 255 ), [Param-InvoicedToDate] Text ( 255 ), [Param-StartDate] DateTime, [Param-EndDate] DateTime, [Param-StagedPayments] Bit, [Param-Retention] Bit, [Param-RetentionPayableDate] DateTime, [Param-RetentionAmount] Text ( 255 ), [Param-Supplier] Text ( 255 ), [Param-ShortDescription] Text ( 255 ), [Param-DescriptionOfWorks] LongText, [Param-Status] Text ( 255 ), [Param-Owner] Text ( 255 ), [Param-Heading] Text ( 255 ), [Param-ParentCommitment] Text ( 255 ), [Param-User] Text ( 255 );
UPDATE tblCommitments SET tblCommitments.Version = [Param-Version], tblCommitments.Type = [Param-Type], tblCommitments.Property = [Param-Property], tblCommitments.TotalContractAmount = [Param-TotalContractAmount], tblCommitments.InvoicedtoDate = [Param-InvoicedtoDate], tblCommitments.StartDate = [Param-StartDate], tblCommitments.EndDate = [Param-EndDate], tblCommitments.StagedPayments = [Param-StagedPayments], tblCommitments.Retention = [Param-Retention], tblCommitments.RetentionPayableDate = [Param-RetentionPayableDate], tblCommitments.RetentionAmount = [Param-RetentionAmount], tblCommitments.Supplier = [Param-Supplier], tblCommitments.ShortDescription = [Param-ShortDescription], tblCommitments.DescriptionOfWorks = [Param-DescriptionOfWorks], tblCommitments.Status = [Param-Status], tblCommitments.[User] = [Param-User], tblCommitments.Owner = [Param-Owner], tblCommitments.Heading = [Param-Heading], tblCommitments.ParentCommitment = [Param-ParentCommitment]
WHERE (((tblCommitments.ID)=[Param-CommID]));
and the three fields which are not being updated/nulled out are tblcommitments.Type
tblcommitments.Owner
& tblcommitments.Heading
tl/dr - Some fields in a VB called update query are not updating...
Anyone have any thoughts on what I've done wrong here?
Feel free to shout up if I've missed any information..
Cheers..
slinky