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

Check to see if info is in memo if not uncheck check box

Status
Not open for further replies.

JOD59

Technical User
Dec 17, 2003
39
US
I have a check box that turns on and off the Visible format of a memo box. I want to be able to automatically uncheck the check box if no information is input in to the memo field. This is what I tried so far with no luck any suggestions would be greatly appreciated

(I have tried it with before and after update also)

Private Sub ElecInspReviewNotes_Exit(Cancel As Integer)
If IsNull(ElecInspReviewNotes) Then
ElecInspReview.Value = 0
End If
End Sub
 
what about triggering on lostfocus.

--Todd


TechnicalUser pretending to be a programmer(shhh… the boss doesn’t know yet)
 
Thanks Todd, It works as far as removing the check mark but It has a few problems. The first problem is you have to have focus to activate which may or may not happen all of the time, 2nd the memo field stays visible after the loss of focus. I think I need more code to get this form to do what I want. Here is how I want it to work. When you check one of the text boxes it will let a memo field corresponding to the subject of the check box to be visible, but if some one checks the box then does not input any information, I want the check box to go blank again and the memo field to not be visible. Any thoughts
 
so in your forms on focus event you need to check the value of the check marks, and set the visible property of the memo field accordingly.
ex.
if ElecInspReview.Value = 0 then
me.ElecInspReviewNotes.visible=false
else
me.ElecInspReviewNotes.visible=true
end if

also add me.ElecInspReviewNotes.visible=false to the if isnull statment.

and in the check box event procedure add a way for the memo box to come backup (me.ElecInspReviewNotesvisible = true)

let me know how you do with it

--Todd


TechnicalUser pretending to be a programmer(shhh… the boss doesn’t know yet)
 
Todd here is all my code (don't LOL) I'm a newbe at this. still can't get it to work the way I would like. The form is set up with the check boxs on the main form then the memo fields on on one of the tabed pages. I'm trying to fail safe it so that if some one enters information and one of the check boxes is unchecked the information is not hidden from site. Thanks for your help so far.


Private Sub ElecInspReview_Click()
If Me.ElecInspReview = True Then
Me.ElecInspReviewNotes.Visible = True
Else: Me.ElecInspReviewNotes.Visible = False
End If
End Sub
Private Sub Form_Open(Cancel As Integer)
DoCmd.Maximize
End Sub

Private Sub JanusPermitReview_Click()
If Me.JanusPermitReview = True Then
Me.JanusPermitReviewNotes.Visible = True
Else: Me.JanusPermitReviewNotes.Visible = False
End If

End Sub
Private Sub JHAReview_Click()
If Me.JHAReview = True Then
Me.JHANotes.Visible = True
Else: Me.JHANotes.Visible = False
End If
End Sub

Private Sub LOTOReview_Click()
If Me.LOTOReview = True Then
Me.LOTOReviewNotes.Visible = True
Else: Me.LOTOReviewNotes.Visible = False
End If
End Sub


Private Sub Title5Review_Click()
If Me.Title5Review = True Then
Me.Title5ReviewNotes.Visible = True
Else: Me.Title5ReviewNotes.Visible = False
End If
End Sub
 
Sorry for the delay. I was not able to get to my computer till now! What exactly dosent work? when you click on the check box for title 5 then what happens? (add a stop command and look to see which way in the if statment it is going, also hover over the field names in the debugger (after it pauses at your stop point) and see what their values are.)

You are also going to need to run something from the form current event to check and set values when you open the form or go to a new record.

Dont worry I am just a beginner also and I do thinks the long/wrong way I know but it gets me there

--Todd


TechnicalUser pretending to be a programmer(shhh… the boss doesn’t know yet)
 
Todd thanks for the help, I figuered it out this morning. What I did was attach the code to the on "CLICK" eventy of the SAVE button on the form. It works great. Here the code I used.

Private Sub Save_Click()
On Error GoTo Err_Save_Click

If IsNull(Me.ElecInspReviewNotes) Then
Me.ElecInspReview.Value = 0
Me.ElecInspReviewNotes.Visible = False
End If

If Not IsNull(Me.ElecInspReviewNotes) Then
Me.ElecInspReview.Value = 1
Me.ElecInspReviewNotes.Visible = True
End If

If IsNull(Me.Title5ReviewNotes) Then
Me.Title5Review.Value = 0
Me.Title5ReviewNotes.Visible = False
End If

If Not IsNull(Me.Title5ReviewNotes) Then
Me.Title5Review.Value = 1
Me.Title5ReviewNotes.Visible = True
End If

If IsNull(Me.JanusPermitReviewNotes) Then
Me.JanusPermitReview.Value = 0
Me.JanusPermitReviewNotes.Visible = False
End If

If Not IsNull(Me.JanusPermitReviewNotes) Then
Me.JanusPermitReview.Value = 1
Me.JanusPermitReviewNotes.Visible = True
End If

If IsNull(Me.LOTOReviewNotes) Then
Me.LOTOReview.Value = 0
Me.LOTOReviewNotes.Visible = False
End If

If Not IsNull(Me.LOTOReviewNotes) Then
Me.LOTOReview.Value = 1
Me.LOTOReviewNotes.Visible = True
End If

If IsNull(Me.JHANotes) Then
Me.JHAReview.Value = 0
Me.JHANotes.Visible = False
End If

If Not IsNull(Me.JHANotes) Then
Me.JHAReview.Value = 1
Me.JHANotes.Visible = True
End If

DoCmd.Hourglass True
DoCmd.DoMenuItem acFormBar, acRecordsMenu, acSaveRecord, , acMenuVer70



Exit_Save_Click:



Me.AllowEdits = False
[Equipment subform].Form.AllowEdits = False

Me.DataEntry = False
[Equipment subform].Form.DataEntry = False

DoCmd.GoToRecord , , acLast
DoCmd.Hourglass False
Exit Sub

Err_Save_Click:
MsgBox Err.Description
Resume Exit_Save_Click
Cmd_Save
End Sub
 
But unless you have some code in the forms oncurrent event if you change records the boxes will not refresh to the correct state.

--Todd


TechnicalUser pretending to be a programmer(shhh… the boss doesn’t know yet)
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top