PDA

View Full Version : HELP - The value you entered isn't valid for this field



mojoes
06-01-2018, 06:32 AM
Hi all,

I have a form with a list of items and when you double click on the item, it copies to a subform. Everything works fine but I added to some of the taks a combo box and when the list related to the combo box is selected, I get error message: " The value you entered isn't valid for this field ". I haven't touched the VBA code just added the code for combo box. This is the code:

Private Sub List_task_Click() 'fills the taskname list box depending on colorblock selection


block.Visible = False


If cmb_freq.Value = "monthly" And List_task.Value = "blue" Then


block.Visible = True
strsql = "Select distinct comment from dailytask where Frequency = [Form]!cmb_freq.value and Color = [Form]!List_task.Value"
block.RowSource = strsql


Else
block.Visible = False
strsql = "SELECT ID, TaskName FROM Dailytask WHERE Frequency = [Form]!cmb_freq.value and Color = [Form]!List_task.Value"
list_taskcolor.RowSource = strsql
list_taskcolor.ForeColor = black

End If

End Sub

Private Sub block_Change() 'show the combo box if the tasks belong to a block - THIS IS THE NEW CODE -

Dim strsql As String


strsql = "Select IDTaskName, TaskName from Dailytask where comment = ([form]!block.value)"
list_taskcolor.RowSource = strsql
list_taskcolor.ForeColor = black


End Sub

Private Sub list_taskcolor_DblClick(Cancel As Integer) 'add the list to the subform


[Dailytask_subform]!IDTaskName = list_taskcolor.Column(0)


End Sub



Any ideas or work arounds are really appreciated

OBP
06-01-2018, 01:14 PM
That kind of message is usually related to a Combo having it's "limit to list" property set to Yes.
Or as a field there is a Validation Rule set.
The other possibility is that the block value you are trying to pass to the combo is text and the Combo is actually storing Numeric Values.

mojoes
06-01-2018, 04:32 PM
Thank you for your prompt response. I'll check the combo settings because the other options without the combo, work perfectly.