How to select a record in a form

RuudVanMens

New member
Local time
Today, 19:09
Joined
Jan 27, 2011
Messages
3
In the meantime (time flies) I am 70 years old, retired and for the first time I am trying to set up a simple database to get a form which will be used by another old guy to make his work a lot easier. Using MS Access 2000 I did setup the next code.


Private Sub Selectievakje32_Click()
If Me.Direct_opgelost = False Then
MsgBox "Ook de andere velden (rechts) invullen!"
Else
MsgBox "De andere velden (rechts) hoeven niet ingevuld te worden!" 'Rest of the fields at the right side will not be used anymore and will be invisible.
End If
If Me.Direct_opgelost = True Then
Me.Doorgegeven_aan.Visible = False
Me.Datum2.Visible = False
Me.Afgehandeld_door.Visible = False
Me.Datum3.Visible = False
Else
If Me.Direct_opgelost = False Then
Me.Doorgegeven_aan.Visible = True
Me.Datum2.Visible = True
Me.Afgehandeld_door.Visible = True
Me.Datum3.Visible = True
End If
End If
End sub


The purpose of this code is: when clicking Selectievakje32 in the form the message box tells the user "De andere velden (rechts)hoeven niet ingevuld te worden!" meaning that the rest of the fields at the right side will not be used anymore and will be invisible.
Only, the purpose is that only those fields of the current record aren't visible. Now all those fields of all records at the right side of Selectievakje32 are not visible and that is not what I want.
I hope to get an answer at this site and if so I am very grateful in advance.


Ruud van Mens
 
Welcome to the forum.

It sounds as if you are dealing with a continuous form? Doing the sort of thing you are a attempting to do in a continuous form is always problematic, as the controls in all records will be effected by the properties/values held in the record that currently holds focus.

Perhaps if you are able to post a copy of your DB, someone will be able to suggest an alternate method to achieve your goal.
 
If John's guess is correct and this is a Continuous View (or Datasheet View) form, Condition Formatting (which is what you're attempting here) can only be done using Condition Formatting from the Format Menu, not through code.

And unfortunately, this does not allow for a control's Visible Property to be manipulated on a record by record basis. The closest you could come would be to Disable the controls Doorgegeven_aan, Datum2, Afgehandeld_door and Datum3.

To do this, in Form Design View, you would
  1. Hold down the <Shift> key then select your four controls
  2. Click on Format Menu
  3. Click on Conditional Formatting
  4. Use the dropdown box under Condition1 and select Expression Is
  5. In next box type in [Direct_opgelost] = -1
  6. Click on the Enable/Disable Icon (Icon to right of the big A Icon)
  7. Click on OK
And you're done.

If, in fact, this is a Single View form, where you only see one record at a time, you can do what you are trying to do here, in code, but you need to place your code to control the controls' Visible Property in the Form_Current() event as well as in the Selectievakje32_Click() event.

Linq ;0)>
 
Thanks very much for both replies! This will help me to go on...

I decided to go on with the possibility of a Single View Form and from there to give my friend (the user) the option via a command button to print his input (that works already), a command button to send his input via E-mail and a command button to view his input.
As far as I can see now: this should be the solution.

Thanks a lot again and if I do not solve the programming for the last two Command Buttons, I hope I may ask your help again.

Ruud
 
Glad we could help, Ruud! Come back as needed! Someone is almost always here!

Linq ;0)>
 
Thanks very much for both replies! This will help me to go on...

I decided to go on with the possibility of a Single View Form and from there to give my friend (the user) the option via a command button to print his input (that works already), a command button to send his input via E-mail and a command button to view his input.
As far as I can see now: this should be the solution.

Thanks a lot again and if I do not solve the programming for the last two Command Buttons, I hope I may ask your help again.

Ruud

Ruud, I have a similare situation where I work with visible and invisible, it will only work in single view form and the code needs to be added both in form on current and the command button event..

Sample;
Code:
Private Sub Form_Current()

If Me.Sale = True Then
    Me.QryMultiDocketMaterialss_subform.Visible = True
    Me.QryMultiDocketMaterialsb_subform.Visible = False
    Me.lblSaleWarning.Visible = True
    Me.lblSalesMsg.Visible = True
    Me.lblBuyMsg.Visible = False
    Me.lblDirt2.Visible = False
    Me.lblDirt4.Visible = False
    Me.txtDirt.Visible = False
Else
    Me.QryMultiDocketMaterialsb_subform.Visible = True
    Me.QryMultiDocketMaterialss_subform.Visible = False
    Me.lblSaleWarning.Visible = False
    Me.lblSalesMsg.Visible = False
    Me.lblBuyMsg.Visible = True
    Me.lblDirt2.Visible = True
    Me.lblDirt4.Visible = True
    Me.txtDirt.Visible = True
       
End If

End Sub



' this is the code I have in the on click event of a listbox but can be behind a command button as well


Private Sub List210_Click()
If Me.Sale = True Then
    Me.QryMultiDocketMaterialss_subform.Visible = True
    Me.QryMultiDocketMaterialsb_subform.Visible = False
    Me.lblSaleWarning.Visible = True
    Me.lblSalesMsg.Visible = True
    Me.lblBuyMsg.Visible = False
    Me.lblDirt2.Visible = False
    Me.lblDirt4.Visible = False
    Me.txtDirt.Visible = False
Else
    Me.QryMultiDocketMaterialsb_subform.Visible = True
    Me.QryMultiDocketMaterialss_subform.Visible = False
    Me.lblSaleWarning.Visible = False
    Me.lblSalesMsg.Visible = False
    Me.lblBuyMsg.Visible = True
    Me.lblDirt2.Visible = True
    Me.lblDirt4.Visible = True
    Me.txtDirt.Visible = True
End If
  
   
    DoCmd.RunCommand acCmdRefreshPage

Groetjes Rinus
 
There's always some folks in the world with the same problems. I think that's why there are forums...:D
 

Users who are viewing this thread

Back
Top Bottom