![]() |
Boxes on form. Datatypes error I think
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 |
Boxes on form. Datatypes error I think
set debLetter = form1.Controls("Deb" & myletter).Value
set crdLetter = form1.Controls("Crd" & myLetter).Value -- Regards, Tom Ogilvy "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 |
Boxes on form. Datatypes error I think
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 |
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 |
Boxes on form. Datatypes error I think
Hi Tom,
Yes I did.! I discovered the manifest error as soon as iI tested, but still managed to post the unrevised code. I actually read my own post and failed to spot that I had pasted the wrong code. Thank you for picking it up,. --- Regards, Norman "Tom Ogilvy" wrote in message ... 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 |
All times are GMT +1. The time now is 02:22 PM. |
Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com