Results 1 to 5 of 5
  1. #1
    Bronze Lounger
    Join Date
    Jan 2001
    Location
    Alzano Lombardo, Italy
    Posts
    1,483
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Condition for tab control's form events doesn't wo (2000)

    In the startup form of the attached mdb, if you select Jan 2, 2004 on the calendar and select the "GRUPPO 2" tab on the tab control, you see the value in the ENERGIA text box is 3600 while the value in the PORT1 text box is zero. I'd like, upon selecting either "GRUPPO 2" or "GRUPPO 3" tab on the tab control, to receive a warning message telling me that when energy is present there must also be some water flow present hence the user should fill the txtQt text box in the main form.
    I've tried to insert the conditional expression
    If Energia > 0 And PORT1 = 0 Then MsgBox "inserire portata gruppi 2 e 3"
    in the subforms Activate and Before Update events and even in the tab control pages'click event but I just can't get the message to pop up when the condition is true like for Jan 2, 2004. What should I do?
    Attached Files Attached Files

  2. #2
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts

    Re: Condition for tab control's form events doesn't wo (2000)

    The On Click event of tab pages doesn't work. You must use the On Change event of the tab control as a whole. The value of the tab control corresponds to the tab page that is selected, starting at 0.

    Private Sub TabCtl0_Change()
    Select Case TabCtl0.Value
    Case 1
    If MG2Dez!Energia > 0 And MG2Dez!PORT1 = 0 Then MsgBox "inserire portata gruppi 2 e 3"
    Case 2
    If MG3Dez!Energia > 0 And MG3Dez!PORT1 = 0 Then MsgBox "inserire portata gruppi 2 e 3"
    End Select
    End Sub

  3. #3
    Bronze Lounger
    Join Date
    Jan 2001
    Location
    Alzano Lombardo, Italy
    Posts
    1,483
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Condition for tab control's form events doesn't wo (2000)

    Thank you Hans,
    Now when I get the warning message for Jan 2, 2004 relevant to the "GRUPPO 2" tab, I try and input a value, say, 240, in the txtQt text box on the main form but I get the error message, "The index or primary key cannot contain a null value".
    Attached Files Attached Files

  4. #4
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts

    Re: Condition for tab control's form events doesn't wo (2000)

    If you select January 2, you set the filter for the form to "Giorno = January 2" (not exactly, but you know what I mean.) There is no record for January 2 yet, so you are on a new record. But the Giorno field is not set anywhere, so you can't save the record. I don't know how to solve this, since - as I have mentioned before - I don't understand how your form works.

  5. #5
    Bronze Lounger
    Join Date
    Jan 2001
    Location
    Alzano Lombardo, Italy
    Posts
    1,483
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Condition for tab control's form events doesn't wo (2000)

    What I don't understand is why, being the PortDez23 table the record source of the main form, I cannot update or add new records to it using the text boxes on the main form.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •