string not getting any value

schalkse

Registered User.
Local time
Today, 17:19
Joined
Apr 20, 2005
Messages
51
Hi, it worked in acces 2000, and now am using acces 2003.
Anybody any clue why the string strVoorstel would not get the value?
It just returns nothing.

here's the code:

Dim strVoorstel As String
Dim lngTel As Long
Dim strQer As String
Dim strDa As String
Dim lngNum As Long

strDa = "Referentienummer"
strQer = "tblKlachten"

lngTel = DCount(strDa, strQer, [Referentienummer])

lngNum = lngTel + 1

If lngNum < 10 Then
strVoorstel = "CC" & strJaartal & "/" & "00" & lngNum
If lngNum < 100 Then
strVoorstel = "CC" & strJaartal & "/" & "00" & lngNum
Else
strVoorstel = "CC" & strJaartal & "/" & lngNum
End If

End If

If strMacht = False Then
Knop283.Visible = False
Else
Knop283.Visible = True
End If

MsgBox strVoorstel
Me.Referentienummer.SetFocus
Referentienummer.Text = strVoorstel
Me.Productiedatum.SetFocus
 
try it like this:

Code:
If lngNum < 10 Then
strVoorstel = "CC" & strJaartal & "/" & "00" & lngNum
ElseIf lngNum > 10 And lngNum < 100 Then
strVoorstel = "CC" & strJaartal & "/" & "00" & lngNum
Else
strVoorstel = "CC" & strJaartal & "/" & lngNum
End If

Note that this line:

Code:
strVoorstel = "CC" & strJaartal & "/" & "00" & lngNum

is the same for two different condition.
 
thanks for finding that error,
String has value now, but not everything is passed.
Only lngNum is passed and the "CC". The "0" or "00" are not passed.
Any idea?
 
where are you supposed to get the value for strjaartal from ? ... i am not seeing it declared as a variable, and neither a value has been assigned to it.
 
when the database is opened strJaartal gets a value from the database preferences, although this doe not seem to work anymore either.
 
Only lngNum is passed and the "CC". The "0" or "00" are not passed.
if lngNum is greater than 100 then "00" wont get passed, there is no option to pass just "0"

If you are just trying to create a number that is CC + strJaartal +/ and three digits then you could try

strVoorstel = "CC" & strJaartal & "/" & right("000" & lngNum,3)

Rather than using the If's

HTH

Peter
 

Users who are viewing this thread

Back
Top Bottom