Hide/Show entries

Takstein

Registered User.
Local time
Today, 12:06
Joined
Jan 31, 2007
Messages
54
Hi


I have a problem with one of my forms. I want to record the costs for our firm, and to do this I use a job number or overhead cost number for inventory receipts. These are entered from two data entries. I need:
-1 entry (either Jobnumber or Overhead number)
-make sure there is one entry in either of them and not two or none

Anyone have an idea on how to "force" this?
 

Attachments

  • form.jpg
    form.jpg
    88.6 KB · Views: 138
You could disable all the other fields until a number is entered in one of you number fields, then use the AfterUpdate and enable all the other fields.
 
I did make some functions using after update, turning one off if the other got data, but when i go to the next post, it stays the same...
And this doesn't really make the field required...

anyways.. i'll keep on trying.. thanks for the input!
 
I did make some functions using after update, turning one off if the other got data, but when i go to the next post, it stays the same...

First of all, Soma_rich is on the right track, but there are some additional things you would need to do.

1. Reset the controls to Enabled=False in the On Current event of the form so that it will require things for the next record. However, you won't want to set those if there is an existing record, so you would want to test to see if there is data first before disabling.

2. You can use the form's BeforeUpdate event to test whethere one or the other is filled out. If either is, then you can let it go on, otherwise you can give a message box that tells them to fill out one or the other and then lets them go on. You would have to use Cancel=True after the message box to cancel the update and stay on the record.
 
Hm... this sounds promising..the problem is that i don't know much about vba.. would i have to use that for this?

what does the on current event do?
 
Yes, VBA is your friend and we can help you in that regard. The current event occurs when a form navigates to a record.
 
Yes, VBA is your friend and we can help you in that regard. The current event occurs when a form navigates to a record.

Sounds even more promising! I'll try my best n see what I can do.. but i'm probably coming back soon for help! Hope you guys don't mind me asking a lot then.. probably some stupid q's as well :P
 
Remember to do some searching for answers too. Most, if not all, of the questions you have will have been answered many, many times before. So, if you can find the answers without asking, that's best. If you can't, then by all means ask.
 
Remember to do some searching for answers too. Most, if not all, of the questions you have will have been answered many, many times before. So, if you can find the answers without asking, that's best. If you can't, then by all means ask.

Hm.. i have been searching some but seem to be stuck. i made it work half way with this:
Private Sub Form_Current()

If Len(Me.JobNumber) > 0 Then
Me.JobNumber.Enabled = True
Me.OverHead.Enabled = False​
ElseIf Len(Me.OverHead) > 0 Then
Me.JobNumber.Enabled = False
Me.OverHead.Enabled = True​

End If
But when i made it a bit more complicated like this:

If Len(Me.JobNumber) > 0 And Len(Me.OverHead) > 0 Then
Me.JobNumber.Enabled = True
Me.OverHead.Enabled = True
'(msgbox<--dont know how yet, saying entry needed)'​
ElseIf Len(Me.JobNumber) > 0 And Len(Me.OverHead) <= 0 Then
Me.JobNumber.Enabled = True
Me.OverHead.Enabled = False​
ElseIf Len(Me.JobNumber) <= 0 And Len(Me.OverHead) > 0 Then
Me.JobNumber.Enabled = False
Me.OverHead.Enabled = True​
but it does not work..

The thing is, I want to force entry in one, and when that happens, disable the other one. but when a new record is being entered, both need to be enabled..

Do i have to use a select case on this? can you use AND in a IF sentence in VBA? (e.g. If( this AND that is tru) THEN....)


Hope someone can help!
 
Takstein I NEED YOUR HELP

Hi Takstein,

I am new Access user and trying to make the similar form what you have made "Inventory Receipt Entry". Can you please send me only form (my email address: mithani@rocketmail.com) so I can have a look and try to take some ideas.

Thanks mate

mithani
 

Users who are viewing this thread

Back
Top Bottom