View Single Post
  #4   Report Post  
Posted to microsoft.public.excel.programming
Tom Ogilvy Tom Ogilvy is offline
external usenet poster
 
Posts: 27,285
Default Boxes on form. Datatypes error I think

did you mean:

Sub Tester()
Dim i As Long
Dim x As Double, y As Double, z As Double

For i = 65 To 74 'Asc("A") to Asc("J")
x = Me.Controls("Acc" & Chr(i)).Value
y = Me.Controls("Deb" & Chr(i)).Value
z = Me.Controls("Crd" & Chr(i)).Value

If x < y - z Then
MsgBox "Out of Balance"
End If
Next

End Sub

Also, an equality check for doubles/calculated double may not be very
satisfying.

--
Regards,
Tom Ogilvy


"Norman Jones" wrote in message
...
Hi Marchell,

Perhaps you could also try something like:

Sub Tester()
Dim i As Long
Dim x As Double, y As Double, z As Double

For i = 65 To 74 'Asc("A") to Asc("J")
Me.Controls("Acc" & Chr(i)).Value = x
Me.Controls("Deb" & Chr(i)).Value = y
Me.Controls("Crd" & Chr(i)).Value = z

If x < y - z Then
MsgBox "Out of Balance"
End If
Next

End Sub


---
Regards,
Norman



"marcbell" wrote in message
oups.com...
Hi,

I have 10 rows of a combobox and 2 text boxes on form1
On each row the combobox is called AccA , DebA, CrdA
next row is AccB , DebB, CrdB.......
I'm trying to write a small bit of code that checks if either DebA or
CrdA < null or blank then there must be a value in AccA. Else display
msbox "Error".
Now check the next line.

I've tried this to no avail.

Public myletter as string

Private Sub but_post_Click()
If form1.Balance < 0 Then
MsgBox "Please ensure that the journal balances to zero before posting"
End
Else

'Now this is where I start getting errors
myletter = "A"
test_acc_incl
myletter = "B"
test_acc_incl


End If



End Sub

Sub test_acc_incl()
Dim Debletter As Object
Dim Crdletter As Object
Dim Accletter As Object
' I tried using the 3 dims as string and variables but that didn't work

Deb = "form1.Deb" & myletter
Crd = "form1.Crd" & myletter
Acc = "form1.Acc" & myletter

Set Debletter = Deb
Set Crdletter = Crd
Set Accletter = Acc

If Debletter < Null Or Crdletter < Null Then
If Accletter = Null Then
MsgBox "Error"

Else
End If

Else
End If
End Sub

Please help,

Thanks,

marc