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

Help running two functions under the 'onCurrent' property.

Status
Not open for further replies.

allcarfan

Programmer
Jan 29, 2003
33
0
0
US
For some reason, this little piece of code does not seem to work. The code is for two different functions that are both run in the form code 'oncurrent'. I tried combinging the two pieces of code to make one, but it didnt work. This is what the code looks like...

Function CheckMe()

Late2.Visible = Not (OpenClosed = "Closed")

Late.Visible = Not (OpenClosed = "Closed")


End Function

Function Test()

Late.Visible = Not (Late > Late2 And Late2 <> 0)

Late2.Visible = Not (Late2 = &quot;0&quot;)

End Function

I have a refresh button on my form that updates the data on the form and saves all of the information. The textboxes that are referenced in the above code, appear when they arent suppose to, appear when they are not suppose to. Appear, then disappear and everything in between. What am i doing wrong?

Basically late and late2 are two different textboxes that have a number of days late calculated from two different dates. The late2 textbox should not be visible when it is equal to &quot;0&quot; (its default value) - however, it appears...sometimes. The rest of the code is pretty self-explanatory if you read it. Please help
 
Since you're not returning a value to the calling code, these procedures should probably be Subs (for instance the Access Function Val() returns the numeric value of the string within the parentheses.

I take it OpenClosed is a Function which tests some global variable?
 
I think the problem is that my code is not recognizing the 'calculated' values that are displayed within the late and late2 textboxes. I am pretty sure that I have it figured out though....but who knows...I am still a noob.
 
If the calculated values are not bound to a field in the table, that may indeed be your problem. Try setting the focus to the name of the textbox, then reading the value of the text:
Text1.setfocus
myvariable = Text1.text
'set the focus back to the correct control

If they are bound to a field in the table, you may need to save the record so that the text in the textbox is saved as part of the record before you reference it in code. Access does not automatically save changes you've made to a record until you leave the record.

DoCmd.RunCommand acCmdSaveRecord

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top