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

form current problem

Status
Not open for further replies.

AFKAFB

Programmer
Aug 22, 2005
26
US

All

I’m using Private Sub Form_Current()

It was working quite well until a user suggested an improvement.

When the form opens on a record, if a value is YES and the values in four other fields are not empty then the four fields should be disabled.

If the form opens and the value is yes and any of the four fields are empty then they should all be enabled.

One or the other works quite well but not the pair of them.

It could be a logic break….

My very basic code is as follows:


Private Sub Form_Current()

If q100.value = “YES” AND _
Cmb_A.value <> “” or_
Cmb_B.value <> “” or _
Cmb_C.value <> “” then

Cmb_A.enabled = false
Cmb_B.enabled = false
Cmb_C.enabled = false

elseIf q100.value = “YES” AND _
Cmb_A.value = “” or_
Cmb_B.value = “” or _
Cmb_C.value = “” then

Cmb_A.enabled = true
Cmb_B.enabled = true
Cmb_C.enabled = true

End if

End sub

The q100.value = “yes” is repeated but it is required.

Regards

Chris


 
hmmm
i've not send a formatting on the form_current for that condition but its making me think perhaps i should.
i think looking at the form it should appear as the first set of conditions.
i know it sounds daft.
if i were to showe you the form you could see what i'm trying to.
does it really matter though
chris
 
AFKAFB said:
[blue]The q100.value = “yes” is [purple]repeated but it is required.[/purple][/blue]
. . . and this:
Code:
[blue]Private Sub Form_Current()
   Dim Bits As Integer
   
   Bits = Bits Or ((Trim(Cmb_A.Value & "") <> “”) * -1)
   Bits = Bits Or ((Trim(Cmb_B.Value & "") <> “”) * -2)
   Bits = Bits Or ((Trim(Cmb_C.Value & "") <> “”) * -4)
   
   If q100.Value = “YES” Then
      If Bits = 7 Then
         Cmb_A.Enabled = False
         Cmb_B.Enabled = False
         Cmb_C.Enabled = False
      Else
         Cmb_A.Enabled = True
         Cmb_B.Enabled = True
         Cmb_C.Enabled = True
      End If
   Else
      [green]'Code for q100 <> "Yes"[/green]
   End If
         
End Sub[/blue]
AFKAFB said:
[blue]if i were to showe you the form you could see what i'm trying to.
does it really matter though[/blue]
[purple]Only as much as you decide to include it, or not![/purple]

Calvin.gif
See Ya! . . . . . .
 
If q100.value = "YES" Then
Cmb_A.Enabled = (Trim(Cmb_A & "") = "" Or Trim(Cmb_B & "") = "" Or Trim(Cmb_C & "") = "")
Cmb_B.Enabled = Cmb_A.Enabled
Cmb_C.Enabled = Cmb_A.Enabled
Else
'Code for q100 <> "Yes"
End If

Hope This Helps, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884 or FAQ181-2886
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top