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

validation through a list box, issues!??

Status
Not open for further replies.

dduffy

Technical User
Jul 30, 2002
20
IE
Perhaps I am going about this the wrong way.

I have a form that has 2 subforms, each subform has an options box. When an option is selected in either of the subforms a query reruns and returns a value (being the sum of all items selected) in a list box in the main form. 1 list box for each subform is on the main form.

Next is where the problem comes in. I then have an exit button on the main form, when this is clicked I need to validate that the 2 listboxes equal each other.

I have done this by using a query to against the 2 queries behind the two list boxes. Then adding another list box to return this value. I am then trying to validate if this value <>0.

E.g. List1 = Sum (amt of total selected records from subform1)
list2 = Sum (amt of total selected records from subform2)

list3 (validation)= Sum (amt of total selected records from subform1)- Sum (amt of total selected records from subform2)

I am usig the following code but I get that same result regardless of what the value in List3 is:

Private Sub closemanualrec_Click()
On Error GoTo closemanualrec_Click_Err

If (Me![List3] <> 0) Or IsNull(Me![List3]) Then
Beep
MsgBox &quot;test&quot;, vbOKOnly, &quot;test1&quot;
End
' Exit Sub
End If

closemanualrec_Click_Exit:
Exit Sub

closemanualrec_Click_Err:
MsgBox Error$
Resume closemanualrec_Click_Exit

End Sub

I can actually see the reult in List3 and with the above code I get the message being returned regardless of the amount being displayed in List3.

Please help!

 
Why not just check if Me.[List1]<>Me.[List2] instead of using a third listbox that reruns both queries?

Also, are you really using a ListBox? Shouldn't you be using a TextBox? ListBoxes are for multi-record lists, not single values.
 
I tried that but it didn't work either. I am using the listboxes as eachg one needs to be sourced form different queries and the textboxes don't seem to handle this so well.

Cheers
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top