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

Controlling input to a form from the result of a subform

Status
Not open for further replies.

UzomaOk

Technical User
Nov 15, 2005
14
0
0
NG
I need help urgently. I am designing a Fuel tracking database for my coy and the fuel dispensed form has a subform linked to a query that determines the quantity already dispensed in the past. I want to disallow futher input to the form if the values i greater than 50. I have managed to get the out put to display on the main form nut i cannot stop further input if above 50. Any ideas?
My brain has blown open. Assistance needed urgently.
 
Hi UzomaOK!
Try this:
Code:
Private Sub Form_Current()
    If Me.[!]YourControlName[/!].Value >= 50 Then
        Me.AllowEdits = False
    Else
        Me.AllowEdits = True
    End If
End Sub

You will need to change the item in red to refer to the actual control on your main form which contains the value you want to test.

Hope this helps.

Tom

Born once die twice; born twice die once.
 
Oops! Should have read your post more closely. If you want to only limit to those above 50, remove the [!]=[/!] from the above code.

Tom

Born once die twice; born twice die once.
 
Hi Thomas. It didn't work. The output of the query ( which should not be greater than 50) displays on the main form and not on the subform. So reference for control should be to the label in form itself. Any more ideas???
 
Hi! Not sure I understand this part:
reference for control should be to the [!]label[/!] in form itself
Are you using code to set the text of the label to the value of your label to the value of a control somewhere?

I will need to see as much detail as you can give about the names of your controls, their locations, the query feeding your form, etc. Sorry about the quick and dirty post, but I made some assumptions about your db structure. [blush]

With a bit more info, I'm sure I can help.

Tom

Born once die twice; born twice die once.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top