Solved

Access Hide fields in form until pressing submit

Posted on 2008-06-25
15
211 Views
Last Modified: 2010-04-21
Greetings,

I have a 2 forms, one form and a subform, that calculates time equations on the fly.  I needed the values to allow for null values that works also.  Problem is that when the calculation have not completed, it shows erroneous numbers.  For example, the total amount show 30 (correct number) but the time left may show 3 (not correct because it hasn't been calculated.)

Is there a way that will allow me to hide the fields until the calculation has been completed by either pressing submit or on enter?

Thanks,

Heather
0
Comment
Question by:Heather_D
  • 9
  • 6
15 Comments
 
LVL 13

Accepted Solution

by:
wiswalld earned 500 total points
ID: 21869811
You could set the visible property to false and in your code for calculate put

Me.Field1.Visible = True
0
 
LVL 13

Expert Comment

by:wiswalld
ID: 21869820
Sounds more like you may want to fix the math problem though
0
 

Author Comment

by:Heather_D
ID: 21869839
Me.Field1.Visible = True

Where exactly do I put this?

The math is working fine but thanks :)

0
 
LVL 13

Expert Comment

by:wiswalld
ID: 21870163
First right click the field and set the visible property for the field to false. Then in the button you said you had to perform calculations or however you do this put this after your math calculations.
0
 

Author Comment

by:Heather_D
ID: 21870964
Thanks but the math calculations are equations in a query.  The calculations are totaled and then the submit button takes the calculations and puts them in a table.  

Can I put the equation above in the submit but I would think that the calculations in the subform would still show.

I appreciate the help,

heather
0
 

Author Closing Comment

by:Heather_D
ID: 31470758
Excellent!! I got it to work with your suggestion.  I had to put it in my subform.

Thanks a bunch,

Heather
0
 

Author Comment

by:Heather_D
ID: 21871386
Seems like once I exit out of the database and open it again, the properties for visible turns back to YES.  Is there a way to make the visible permanently no?
0
Get up to 2TB FREE CLOUD per backup license!

An exclusive Black Friday offer just for Expert Exchange audience! Buy any of our top-rated backup solutions & get up to 2TB free cloud per system! Perform local & cloud backup in the same step, and restore instantly—anytime, anywhere. Grab this deal now before it disappears!

 

Author Comment

by:Heather_D
ID: 21871465
One other question, It works fine but when I go to the next record, the fields are visible on the form. If I close the form and reopen, then it works again.

Do I need to add something like me.requery or me.refresh.

I tired both and nothing is working.

Heather
0
 
LVL 13

Expert Comment

by:wiswalld
ID: 21873917
I don't see how a requery would help that. Are you using the access built in navigator at the bottom of the form or your own custom buttons? That was why I reccomended maybe a math problem. You could have set the field to something like

If Me.Field1 = "" Then
Me.Field1.Visible = False
Else
Me.Field1.Visible = True
End If

That way if your math calculation had yet to be done the field would be invisible. You probably could still do this though with your existing math. Does the field always show the same value before the calculation? If so then

If Me.Field1 = "3" Then
Me.Field1.Visible = False
Else
Me.Field1.Visible = True
End If
0
 
LVL 13

Expert Comment

by:wiswalld
ID: 21873919
But give the requery a try first if that will work.
0
 

Author Comment

by:Heather_D
ID: 21875890
Requery is not working.  What is happening is 2 things:

1) the default visible switches from no to yes when the database is reopened
2) when the form is first open, all fields are hidden and works great when pressing the submit button.  The form then goes blank allowing for new fields to be inputted.  When that happens, the invisible fields are visible again.  If I switch from the designer back to view, the fields are invisible again.  That was why i was thinking a requery or refresh or something to make the form think that it's just being open or something.

As for the code:

If Me.Field1 = "" Then
Me.Field1.Visible = False
Else
Me.Field1.Visible = True
End If

I'll give this a try and see what happens.

Thanks!  I wish I could give you another 500 points for this one :)

Heather
0
 

Author Comment

by:Heather_D
ID: 21875972
Tried the
If Me.Field1 = "" Then
Me.Field1.Visible = False
Else
Me.Field1.Visible = True
End If

Didn't work.  I was thinking that the fields are not null but contains some erroneous number before the final calculation.  That is why that is not working.  Also, I did a test to remove the
Me.Field1.Visible = True
 and the fields remained hidden on for the next records on the form.

Is there a way to say if going to new ID, make the fields invisible again.  I am thinking that it is making it visible when a field is populated (which is correct) but not switching it back to invisible for the next record.

thanks,

heather
0
 

Author Comment

by:Heather_D
ID: 21876200
Also the left field is in an append table so there never is a null blank record.

0
 
LVL 13

Expert Comment

by:wiswalld
ID: 21876597
To do these calculations I am guessing you have at least two fileds and then the third field(the invisible one) to perform the calculations. If they are normally blank or would be blank when you go to a new record then what about this in the on current for the form:

If Me.Field1 = "" Then   'Field1 would be a normal field for the calculations
Me.Field2.Visible = True   'Field2 would be the field we want to make visible/invisible
Else
Me.Field2.Visible = False
End If





0
 

Author Comment

by:Heather_D
ID: 21876804
Okay, I got two fields on my main form to work by setting the Me.RoundTotal.visible = False after the submit button. That seemed to make the field invisible again for the next record.  However, I can't get the Left field which is in the subform to work that way. I have tried everything form exit, after update, etc and nothing is turning the visibility back to false. I can manually go into the properties and set the visibility to no and it will work on the form.

How can I control a subform field from the main form? I am thinking if I can make the left field go back to invisible at the submit on the main form, that might work.

Thanks,

heather
0

Featured Post

IT, Stop Being Called Into Every Meeting

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

QuickBooks® has a great invoice interface that we were happy with for a while but that changed in 2001 through no fault of Intuit®. Our industry's unit names are dictated by RUS: the Rural Utilities Services division of USDA. Contracts contain un…
If you have heard of RFC822 date formats, they can be quite a challenge in SQL Server. RFC822 is an Internet standard format for email message headers, including all dates within those headers. The RFC822 protocols are available in detail at:   ht…
Learn how to number pages in an Access report over each group. Activate two pass printing by referencing the pages property: Add code to the Page Footers OnFormat event to capture the pages as there occur for each group. Use the pages property to …
In Microsoft Access, learn different ways of passing a string value within a string argument. Also learn what a “Type Mis-match” error is about.

743 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

10 Experts available now in Live!

Get 1:1 Help Now