3 Replies - 1169 Views - Last Post: 04 February 2012 - 05:10 AM

Topic Sponsor:

#1 oMADMANo  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 19
  • Joined: 21-January 12

only edit current record ?

Posted 02 February 2012 - 01:20 PM

okay so I have a form called "Membership" and a tick box "Riskassesment" using the control source "Riskassesment" from the table "Membership Database" set up to a yes/no option. Im attempting to have my code only change the current record and display the text boxes and buttons I have made
called "Risk" (label) , "Risk1" (label) , " Risktext" (text box) , "Risk1text" (text box) , "RiskButton" (button).

This is an example of the code I am trying to use
Private Sub RiskAssesment_AfterUpdate()

 Set db = CurrentDb
 Set rs = db.OpenRecordset("Membership Database", dbOpenDynaset)
    
   
   
   If vbFalse(rs![RiskAssesment]) Then
     Me.Risk.Visible = False
       
   ElseIf vbTrue(rs![RiskAssesment]) Then
     Me.Risk.Visible = True
    
   End If

End Sub


but I get the error "expected array"

I have tried

If me.RiskAssesment = False Then

me.Risk.Visible = False

ElseIf me.RiskAssesment = True Then

me.Risk.Visible = True



but it updates all records.
Please help me fix this.

Is This A Good Question/Topic? 0
  • +

Replies To: only edit current record ?

#2 June7  Icon User is offline

  • D.I.C Addict
  • member icon

Reputation: 95
  • View blog
  • Posts: 859
  • Joined: 09-December 08

Re: only edit current record ?

Posted 02 February 2012 - 01:48 PM

Try simply:

Me.Risk.Visible = Me.RiskAssessment

vbFalse and vbTrue are not functions, they are constants.

So expression could be:
If Me.RiskAssessment = vbFalse

This post has been edited by June7: 02 February 2012 - 01:50 PM

Was This Post Helpful? 0
  • +
  • -

#3 tlhIn`toq  Icon User is online

  • WillMyCodeWork = !FailedWhenYouTriedIt;
  • member icon

Reputation: 3290
  • View blog
  • Posts: 6,896
  • Joined: 02-June 10

Re: only edit current record ?

Posted 02 February 2012 - 01:50 PM

Quote

tick box "Riskassesment"


If me.RiskAssesment = False Then



If you mean "checkbox"... A checkbox cannot be true or false. Its a GUI object. Whether or not it is checked can be true or false however.

You're checking if the control is false, not if the .Checked property is.
Was This Post Helpful? 0
  • +
  • -

#4 oMADMANo  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 19
  • Joined: 21-January 12

Re: only edit current record ?

Posted 04 February 2012 - 05:10 AM

SOLVED ! thanks
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1