Pedro Janssen
pedro at plex.nl
Sat Jul 19 14:36:22 CDT 2003
Hi Scott,
because i had 10 chbProductCode's i placed
ElseIf chbProductCode3 = true then
strNumber = "3"
bolFound = True
etc. etc in the code.
chbProductCode 1 and 2 are working fine.
>From 3 i get an error.
Error No: 5; Description: Invalid procedure-calling or invalid argument
(I'll hope i have got the translation right, because we are using Dutch versions)
I can't figure out why this error exists.
Pedro
----- Original Message -----
From: tsm at zoomtown.com
To: Access Developers discussion and problem solving
Sent: Saturday, July 19, 2003 12:49 AM
Subject: Re: Re: [AccessD] shorter and quicker code
Pedro,
I was working off the top of my head and forgot some stupid stuff so I fixed it. Also, this may be faster to write but it will run slower.
Dim strNumber as String
Dim bolFound as Boolean
bolFound = False
If chbProductCode1 = true then
strNumber = "1"
bolFound = True
ElseIf chbProductCode2 = true then
strNumber = "2"
bolFound = True
EndIf
If bolFound = True then
.Item("ProductCode" & strNumber).Value = Nz(Me("txtProductCode" & _
strNumber))
.Item("Number" & strNumber).Value = Nz(Me![txtNumber])
If chbA1 = True then
.Item("Price" & strNumber).Value = Nz(Me("txt" & _
strNumber & "c16"))
ElseIf chbA2 = True then
.Item("Price" & strNumber).Value = Nz(Me("txt" & _
strNumber & "c17"))
ElseIf chbA3 = True then
.Item("Price" & strNumber).Value = Nz(Me("txt" & _
strNumber & "c18"))
ElseIf chbUitz1 = True then
.Item("Number" & strNumber).Value = Nz(Me("txtUitz" & _
strNumber & "Number"))
.Item("Price" & strNumber).Value = Nz(Me("txtUitz" & _
strNumber & "Price"))
End If
End If
Scott
From: <tsm at zoomtown.com>
Date: 2003/07/18 Fri PM 06:38:12 EDT
To: Access Developers discussion and problem solving
<accessd at databaseadvisors.com>
Subject: Re: [AccessD] shorter and quicker code
Pedro,
Try the following:
Dim strNumber as String
Dim bolFound as Boolean
bolFound = False
If chbProductCode1 = true then
strNumber = 1
bolFound = True
ElseIf chbProductCode2 = true then
strNumber = 2
bolFound = True
EndIf
If bolFound = True then
.Item("ProductCode" & strNumber).Value = Nz(Me![txtProductCode1])
.Item("Number" & strNumber).Value = Nz(Me![txtNumber])
If chbA1 = True then
.Item("Price" & strNumber).Value = Nz(Me("txt" & _
strNumber & "c16"))
ElseIf chbA2 = True then
.Item("Price" & strNumber).Value = Nz(Me("txt" & _
strNumber & "c17"))
ElseIf chbA3 = True then
.Item("Price" & strNumber).Value = Nz(Me("txt" & _
strNumber & "c18"))
ElseIf chbUitz1 = True then
.Item("Number" & strNumber).Value = Nz(Me("txtUitz" & _
strNumber & "Number"))
.Item("Price" & strNumber).Value = Nz(Me("txtUitz" & _
strNumber & "Price"))
End If
End If
Scott
From: "Pedro Janssen" <pedro at plex.nl>
Date: 2003/07/18 Fri PM 05:31:35 EDT
To: <AccessD at databaseadvisors.com>
Subject: [AccessD] shorter and quicker code
Hello Group,
the code below is part of a code that i have to write in about five versions for 10 ProductCode's.
This is a lot of typing, copying, pasting and you can't let your mind slip away, otherwise you make mistakes. Is there a shorter and quicker way?
TIA
Pedro Janssen
If chbProductCode1= True then
.Item("ProductCode1").Value = Nz(Me![txtProductCode1])
If chbA1 = True then
.Item("Number1").Value = Nz(Me![txtNumber])
.Item("Price1").Value = Nz(Me![txt1c16])
ElseIf chbA2 = True then
.Item("Number1").Value = Nz(Me![txtNumber])
.Item("Price1").Value = Nz(Me![txt1c17])
ElseIf chbA3 = True then
.Item("Number1").Value = Nz(Me![txtNumber])
.Item("Price1").Value = Nz(Me![txt1c18])
ElseIf chbUitz1 = True then
.Item("Number1").Value = Nz(Me![txtUitz1Number])
.Item("Price1").Value = Nz(Me![txtUitz1Price])
End If
End If
If chbProductCode2= True then
.Item("ProductCode2").Value = Nz(Me![txtProductCode2])
If chbA1 = True then
.Item("Number2").Value = Nz(Me![txtNumber])
.Item("Price2").Value = Nz(Me![txt2c16])
ElseIf chbA2 = True then
.Item("Number2").Value = Nz(Me![txtNumber])
.Item("Price2").Value = Nz(Me![txt2c17])
ElseIf chbA3 = True then
.Item("Number2").Value = Nz(Me![txtNumber])
.Item("Price2").Value = Nz(Me![txt2c18])
ElseIf chbUitz2 = True then
.Item("Number2").Value = Nz(Me![txtUitz2Number])
.Item("Price2").Value = Nz(Me![txtUitz2Price])
End If
End If
_______________________________________________
AccessD mailing list
AccessD at databaseadvisors.com
http://databaseadvisors.com/mailman/listinfo/accessd
Website: http://www.databaseadvisors.com
------------------------------------------------------------------------------
Hello Group,
the code below is part of a code that i have to write in about five versions for 10 ProductCode's.
This is a lot of typing, copying, pasting and you can't let your mind slip away, otherwise you make mistakes. Is there a shorter and quicker way?
TIA
Pedro Janssen
If chbProductCode1= True then
.Item("ProductCode1").Value = Nz(Me![txtProductCode1])
If chbA1 = True then
.Item("Number1").Value = Nz(Me![txtNumber])
.Item("Price1").Value = Nz(Me![txt1c16])
ElseIf chbA2 = True then
.Item("Number1").Value = Nz(Me![txtNumber])
.Item("Price1").Value = Nz(Me![txt1c17])
ElseIf chbA3 = True then
.Item("Number1").Value = Nz(Me![txtNumber])
.Item("Price1").Value = Nz(Me![txt1c18])
ElseIf chbUitz1 = True then
.Item("Number1").Value = Nz(Me![txtUitz1Number])
.Item("Price1").Value = Nz(Me![txtUitz1Price])
End If
End If
If chbProductCode2= True then
.Item("ProductCode2").Value = Nz(Me![txtProductCode2])
If chbA1 = True then
.Item("Number2").Value = Nz(Me![txtNumber])
.Item("Price2").Value = Nz(Me![txt2c16])
ElseIf chbA2 = True then
.Item("Number2").Value = Nz(Me![txtNumber])
.Item("Price2").Value = Nz(Me![txt2c17])
ElseIf chbA3 = True then
.Item("Number2").Value = Nz(Me![txtNumber])
.Item("Price2").Value = Nz(Me![txt2c18])
ElseIf chbUitz2 = True then
.Item("Number2").Value = Nz(Me![txtUitz2Number])
.Item("Price2").Value = Nz(Me![txtUitz2Price])
End If
End If
------------------------------------------------------------------------------
_______________________________________________
AccessD mailing list
AccessD at databaseadvisors.com
http://databaseadvisors.com/mailman/listinfo/accessd
Website: http://www.databaseadvisors.com
------------------------------------------------------------------------------
_______________________________________________
AccessD mailing list
AccessD at databaseadvisors.com
http://databaseadvisors.com/mailman/listinfo/accessd
Website: http://www.databaseadvisors.com
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://databaseadvisors.com/pipermail/accessd/attachments/20030719/bd5f8c7c/attachment-0001.html>