Marchese Il Chihuahua
Marchese Il Chihuahua

Reputation: 1129

Creating a value in a control on a form

I need to create a value in a text box control upon triggering a certain event to allow me to then relink my forms to a different master/child link scheme. This value is to be used subsequently to create an if statement. For some strange reason, the value is generated and formatted correctly but regardless of what is in the text box, the If statement does not recognise this value and knows it only as blank. I tried numbers, letters but everything is the same.

In my example below, after updating the control (text box) 'txtDeviation' to the value of '1', for some strange reason is not recognised in as the value 1.

Private Sub cmdSkillsTracking_Click()

 Form_frmValueChain01!frmValueChain02.SetFocus
 Form_frmValueChain01.Pagina370.Visible = False
 Form_frmValueChain01.Pagina371.Visible = True

If txtDeviation01 < 1 Then

    Form_frmValueChain01.Form.frmValueChain07.LinkMasterFields = "txtMicroProcess01e"
    Form_frmValueChain01.Form.frmValueChain07.LinkChildFields = "ID"

    Form_frmValueChain01.Form.frmValueChain17.LinkMasterFields = "txtSubProcessID"
    Form_frmValueChain01.Form.frmValueChain17.LinkChildFields = "IDskillsmatrix"

    Form_frmValueChain01.Form.frmValueChain16.LinkMasterFields = "txtSubProcessID"
    Form_frmValueChain01.Form.frmValueChain16.LinkChildFields = "ID"

Else

     Form_frmValueChain01.Form.frmValueChain07.LinkMasterFields = "txtMicroProcess01f"
    Form_frmValueChain01.Form.frmValueChain07.LinkChildFields = "ID"

    Form_frmValueChain01.Form.frmValueChain14.LinkMasterFields = "txtMicroProcess01f"
    Form_frmValueChain01.Form.frmValueChain14.LinkChildFields = "subprocessID"

    Form_frmValueChain01.Form.frmValueChain10c.LinkMasterFields = "txtMicroProcess01f"
    Form_frmValueChain01.Form.frmValueChain10c.LinkChildFields = "ID"

    Form_frmValueChain01.Form.frmValueChain101.LinkMasterFields = "txtMicroProcess01f"
    Form_frmValueChain01.Form.frmValueChain101.LinkChildFields = "ID"

    Form_frmValueChain01.Form.frmValueChain07.LinkMasterFields = "txtMicroProcess01e"
    Form_frmValueChain01.Form.frmValueChain07.LinkChildFields = "ID"

    Form_frmValueChain01.Form.frmValueChain17.LinkMasterFields = "txtSubProcessID"
    Form_frmValueChain01.Form.frmValueChain17.LinkChildFields = "IDskillsmatrix"

    Form_frmValueChain01.Form.frmValueChain16.LinkMasterFields = "txtSubProcessID"
    Form_frmValueChain01.Form.frmValueChain16.LinkChildFields = "ID"
End If

Upvotes: 0

Views: 52

Answers (1)

ThreadingLightly
ThreadingLightly

Reputation: 36

Two things I see here;

  1. Since you are using a less than operator, you seem to want to treat this text box value as numeric. If so, you will need to convert the text value of the text box to numeric.
  2. Next,you need to prefix the reference to the text box with "me."

Your IF statement should look like this;

If val(me.txtDeviation01) < 1 Then
...

Upvotes: 1

Related Questions