Updating a field within a form

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

I have a data-entry form where users enter in data that goes into a Header table

However, I am trying to add a check box (yes/no) that users can check to say if a plan is required
If a plan is required, I would like an inputbox to come up that asks "Is this plan documented?" If they click yes, it will update the field called "Documented_Plan" in the Header table. If they click no, it will also update the Documented_Plan field, but it will insert "No" instead of "Yes".

I am guessing I would need to use an If...Then...Else statement, but I am unsure how to get the inputbox values of "Yes" or "No" to populate into the header table

Any suggestions

Thanks in advance
Matt
 
lets say you have a control named Documented_Plan on the
form. It should be hidden.

The MsgBox function can return a value.


Me.Documented_Plan = MsgBox("Is this plan
documented",vbYesNo)=vbYes

Or, the longer version
If MsgBox("Is this plan documented",vbYesNo)=vbYes then
Me.Documented_Plan = True
Else
Me.Documented_Plan = False
End If


Chris

-----Original Message-----
I have a data-entry form where users enter in data that goes into a Header table.

However, I am trying to add a check box (yes/no) that
users can check to say if a plan is required.
If a plan is required, I would like an inputbox to come
up that asks "Is this plan documented?" If they click
yes, it will update the field called "Documented_Plan" in
the Header table. If they click no, it will also update
the Documented_Plan field, but it will insert "No" instead
of "Yes".
I am guessing I would need to use an If...Then...Else
statement, but I am unsure how to get the inputbox values
of "Yes" or "No" to populate into the header table.
 
I have a data-entry form where users enter in data that goes into a Header table.

However, I am trying to add a check box (yes/no) that users can check to say if a plan is required.
If a plan is required, I would like an inputbox to come up that asks "Is this plan documented?" If they click yes, it will update the field called "Documented_Plan" in the Header table. If they click no, it will also update the Documented_Plan field, but it will insert "No" instead of "Yes".

I am guessing I would need to use an If...Then...Else statement, but I am unsure how to get the inputbox values of "Yes" or "No" to populate into the header table.

Use the AfterUpdate event of the checkbox:

Private Sub chkPlanRequired_AfterUpdate()
If Me!chkPlanRequired = False Then
Me!Documented_Plan = "No"
Else
Me!Documented_Plan = "Yes"
End If
End Sub

You could of course just define Documented_Plan as a Yes/No field,
formatted Yes/No, and bind a textbox to it - no need to have two
controls where one will contain the information you need!
 
Thanks for the code

I tried both the code from Chris and John, but for some reason when the code runs in the form, it keeps on giving me the following error

Compile error

Ambiguous name detected: Form_Time

Any idea why this error message is coming up? Other times it will give me the same message but refer to some other name. I don't know why this is coming up since the code seems right to me

Thanks in advance
Matt
 
Ambiguous name detected: Form_Timer

Any idea why this error message is coming up? Other times it will give me the same message but refer to some other name. I don't know why this is coming up since the code seems right to me.

It means that you have TWO lines in your form's module saying

Private Sub Form_Timer()

Open the Code Module for the form and search; delete one of the Sub...
End Sub sets of code.

It may also mean that the form (or its module) have become corrupted.

Has nothing to do with the update code though!
 
Back
Top