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

correct enable code 1

Status
Not open for further replies.

PROXI

Vendor
Sep 16, 2003
136
US
This is the code that I have. I have 2 problems.
1) Is there a better way of doing this than this drawn out version.
2) Since putting this code in, now the shippedLW field is overwritten with 12/12/1899.

Does anyone know what is going on and how to fix this?

If Form_Main.YNDeleted = -1 Then
Form_Main.Last.enabled = False
Form_Main.First.enabled = False
Form_Main.Loan.enabled = False
Form_Main.ShippedLW = False
Form_Main.Adversed_Date.enabled = False
Form_Main.Team.enabled = False
Form_Main.Date_Audited.enabled = False
Form_Main.Loan_Type.enabled = False
Form_Main.LO.enabled = False
Form_Main.Checked.enabled = False
Form_Main.Shipped.enabled = False
Form_Main.Barcode.enabled = False
Form_Main.Trackingnum.enabled = False
Form_Main.YNHeloc.enabled = False
Form_Main.YNLW.enabled = False
Form_Main.YNMLCS.enabled = False
Form_Main.Shipped.enabled = False
Else
Form_Main.Last.enabled = True
Form_Main.First.enabled = True
Form_Main.Loan.enabled = True
Form_Main.ShippedLW = True
Form_Main.Adversed_Date.enabled = True
Form_Main.Team.enabled = True
Form_Main.Date_Audited.enabled = True
Form_Main.Loan_Type.enabled = True
Form_Main.LO.enabled = True
Form_Main.Checked.enabled = True
Form_Main.Shipped.enabled = True
Form_Main.Barcode.enabled = True
Form_Main.Trackingnum.enabled = True
Form_Main.YNHeloc.enabled = True
Form_Main.YNLW.enabled = True
Form_Main.YNMLCS.enabled = True
Form_Main.Shipped.enabled = True
End If



Thanks,

PROXI
 
If you are enabling the date but not entering anything into the field is it just that access is inputting the first date it knows?

dyarwood
 
but if there is a value that is already in the field. Why would it not be disabling the field and overwritting the value?

Thanks,

PROXI
 
Here's a little code that might help. It makes use of the control's tag properties in this case, to set visibility of a number of controls depending on a condition.

You can do a search on Fancy Prairie, who helped me out in understanding the use of tag properties and getting it right.

Dim ctl As Control

For Each ctl In Me.Controls '

If ctl.Tag = "1" Then
If Me.txtSpec = "-000" Or Me.txtSpec = "-100" Or Me.txtSpec = "-200" Then
ctl.Visible = True
Else
ctl.Visible = False
End If
End If
 
Hi PROXI!

I'm using rather similar code myself (either your variant or some "version" of what pdldavis presents), so no help on that, but the datecontrol - all the other controls have their enabled properties set to false.

For your datecontrol (Form_Main.ShippedLW) you set the controls value (not the property, you've just forgotten to add .enabled behind the control) to either false or true (respectively 0 and -1 - which formatted to date are late Desember 1899).

HTH Roy-Vidar
 
Good catch RoyVidar. Another example of which I have such distate for "default properties".

One way to both simplify and speed up the code, with color emphasis on that which RoyVidar pointed out, would be the following.
Code:
Dim SetEnable as Boolean

SetEnable = (Form_Main.YNDeleted = -1)
With Form_Main
   .Last.enabled = SetEnable 
   .First.enabled = SetEnable 
   .Loan.enabled = SetEnable 
   .ShippedLW
Code:
.enabled
Code:
 = SetEnable 
   .Adversed_Date.enabled = SetEnable 
   .Team.enabled = SetEnable 
   .Date_Audited.enabled = SetEnable 
   .Loan_Type.enabled = SetEnable 
   .LO.enabled = SetEnable 
   .Checked.enabled = SetEnable 
   .Shipped.enabled = SetEnable 
   .Barcode.enabled = SetEnable 
   .Trackingnum.enabled = SetEnable 
   .YNHeloc.enabled = SetEnable 
   .YNLW.enabled = SetEnable 
   .YNMLCS.enabled = SetEnable 
   .Shipped.enabled = SetEnable 
End With

Good Luck
--------------
As a circle of light increases so does the circumference of darkness around it. - Albert Einstein
 
Thanks for the help cajun. It worked great. The only modification that I had to do was to change the value from -1 to 0.

Thanks,

PROXI
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top