Hello,
Step 1
Create function to hide or show buttons dependent on date field enabled true/false.
These buttons will overlay each other accordingly.
By Default the Date Fields are Enabled = False
! - Lots of buttons to code
? - Can I clean this up to be not so repetitive?
This function to be "Called" in:
Form - Load, Open, anywhere else?
The Following is where I am not sure if the code can/should be working off an enabled.true/false senario?
Step 2 (See Step 3, this could be the other way around?)
The Lock Button on click
Makes the corrosponding Date Field.Enabled = True
Enables the user to change the date.
The UnLock Button on click
Makes the corrosponding Date Field.Enabled = False
Step 3 (Problem/Issues)
The Target dates are automatically populated thru a series of complicated code.
When enabling/changing dates, I need to be able to fix these dates into position without them being updated
the next time that code is run.
Also I will need to be able to re-activate/reset all of the target dates to update with the code if necessary.
? - Do I code it to say If Date Field.Enabled = True then ignore update for this field
But then the field is unlocked/enabled
? - Do I have the target date fields.enabled = True by default then if lock button clicked sets the date field.enabled = False
Then if date field.enabled = false don't run update code on those fields.
The Update Code is as follows:
Thank you
Step 1
Create function to hide or show buttons dependent on date field enabled true/false.
These buttons will overlay each other accordingly.
By Default the Date Fields are Enabled = False
! - Lots of buttons to code
? - Can I clean this up to be not so repetitive?
This function to be "Called" in:
Form - Load, Open, anywhere else?
Code:
' Hide/Show Buttons for locking/unlocking dates
Public Function VisLock()
If TxtCarcassCut_Due.Enabled = False Then
BtnUnLock_CC.Visible = True
BtnLock_CC.Visible = False
If TxtCarcassEdge_Due.Enabled = False Then
BtnUnLock_CCE.Visible = True
BtnLock_CCE.Visible = False
' If etc.
' etc....
Else
BtnUnLock_CC.Visible = False
BtnLock_CC.Visible = True
BtnUnLock_CCE.Visible = False
BtnLock_CCE.Visible = True
' etc...
End If
End If
End Function
The Following is where I am not sure if the code can/should be working off an enabled.true/false senario?
Step 2 (See Step 3, this could be the other way around?)
The Lock Button on click
Makes the corrosponding Date Field.Enabled = True
Enables the user to change the date.
The UnLock Button on click
Makes the corrosponding Date Field.Enabled = False
Step 3 (Problem/Issues)
The Target dates are automatically populated thru a series of complicated code.
When enabling/changing dates, I need to be able to fix these dates into position without them being updated
the next time that code is run.
Also I will need to be able to re-activate/reset all of the target dates to update with the code if necessary.
? - Do I code it to say If Date Field.Enabled = True then ignore update for this field
But then the field is unlocked/enabled
? - Do I have the target date fields.enabled = True by default then if lock button clicked sets the date field.enabled = False
Then if date field.enabled = false don't run update code on those fields.
The Update Code is as follows:
Code:
'------------------------------------------------------------
'Update Dates and Form
'
'------------------------------------------------------------
Private Sub BtnUpdate_Click()
Dim db As Database
Dim sql As String, sVal1 As String, sVal2 As String
Dim con As Object
Dim rs As Object
Dim dDate As Date
Dim iLoop As Integer, iDays As Integer, iAcct As Integer
Set con = Application.CurrentProject.Connection
Set db = CurrentDb
If ChkScheduled = True Then
Me!CboJobTypeID.Enabled = False
Me!TxtCustomerPreferredDate.Enabled = False
Else
CboJobTypeID.SetFocus
If CboJobTypeID.text = "" And Nz(Me.Lead_Date, "") = "" Then
Exit Sub
End If
If CboJobTypeID.text = "" Then
MsgBox "Please select a Job Type from the list", vbInformation, "Select Job Type"
Exit Sub
End If
If (Lead_Date.Value & "" = "") And (ChkIFA_App = True) Then
Lead_Date.Value = Now()
End If
End If
Me.Refresh
iDays = 0
If ChkIFA_App = True Then
sql = "UPDATE JobInfoT SET IFA_Due = #" & addDays(GetDays("IFA_Due"), 2) & "#,SampleSubm_Due = #" & addDays(GetDays("SampleSubm_Due"), 2) & _
"#,IFC_Due = #" & addDays(GetDays("IFC_Due"), 1) & "#,SetOutDue = #" & addDays(GetDays("SetOutDue"), 1) & _
"#,CarcassCut_Due = #" & addDays(GetDays("CarcassCut_Due"), 1) & "#,CarcassEdge_Due = #" & addDays(GetDays("CarcassEdge_Due"), 1) & _
"#,PFBCut_Due = #" & addDays(GetDays("PFBCut_Due"), 1) & "#,PFBEdge_Due = #" & addDays(GetDays("PFBEdge_Due"), 1) & _
"#,WhiteSatinCut_Due = #" & addDays(GetDays("WhiteSatinCut_Due"), 1) & "#,TwoPakPartsOut_Due = #" & addDays(GetDays("TwoPakPartsOut_Due"), 1) & _
"#,PickHW_Due = #" & addDays(GetDays("PickHW_Due"), 1) & "#,HingeDrill_Due = #" & addDays(GetDays("HingeDrill_Due"), 1) & _
"#,MachineShop_Due = #" & addDays(GetDays("MachineShop_Due"), 1) & "#,DrawerAss_Due = #" & addDays(GetDays("DrawerAss_Due"), 1) & _
"#,AssemblyDue = #" & addDays(GetDays("AssemblyDue"), 1) & "#,TwoPakUnderC_Due = #" & addDays(GetDays("TwoPakUnderC_Due"), 1) & _
"#,TwoPakPaint_Due = #" & addDays(GetDays("TwoPakPaint_Due"), 1) & "#,WrapQC_Due = #" & addDays(GetDays("WrapQC_Due"), 1) & _
"#,Delivery_Due = #" & addDays(GetDays("Delivery_Due"), 1) & "# WHERE JobID = " & Me.JobID
Else
sql = "UPDATE JobInfoT SET IFA_Due = #" & addDays(GetDays("IFA_Due"), 2) & "#,SampleSubm_Due = #" & addDays(GetDays("SampleSubm_Due"), 2) & _
"#,IFC_Due = """",SetOutDue = """",CarcassCut_Due = """",CarcassEdge_Due = """",PFBCut_Due = """",PFBEdge_Due = """",WhiteSatinCut_Due = """",TwoPakPartsOut_Due = """", PickHW_Due = """",HingeDrill_Due = """",MachineShop_Due = """",DrawerAss_Due = """",AssemblyDue = """",TwoPakUnderC_Due = """",TwoPakPaint_Due = """",WrapQC_Due = """",Delivery_Due = """" WHERE JobID = " & Me.JobID
End If
db.Execute sql
DoCmd.DoMenuItem acFormBar, acRecordsMenu, acSaveRecord, , acMenuVer70
Me.Refresh
End Sub
Thank you