troubleshooting Question

How do I convert double to string?

Avatar of cklosko
cklosko asked on
Microsoft Access
5 Comments2 Solutions1185 ViewsLast Modified:
I need to auto populate an Id field with 999999991, then 999999992, etc. when an Id is not entered by the user. The Id is text, since the user wants to use a leading 0 in the Id, such as 043-432-098. So, I am converting the text to a double, so as to be able to add 1 (when I used int, I got an overflow error). Then, I need to convert this new number, 999999992, for example, back to a text string. My code looks, as follows:
Dim MaxForcedANumber As String
Dim ANumberDbl As Double

'If ANumber was not entered, force 99999999x
If IsNull(Me.ANumber) = True Then
  'Search for largest A Number in database (forced A Numbers are largest)
  MaxForcedANumber = DMax("ANumber", "tbl_AllClients")
  ANumberDbl = CDbl(MaxForcedANumber) + 1
  Me.ANumber = Mid(ANumberDbl, 1, 3) & "-" & Mid(ANumberDbl, 4, 3) & "-" & Mid(ANumberDbl, 7, 3)
 End If
I get a type mismatch error. What is incorrect?
Join our community to see this answer!
Unlock 2 Answers and 5 Comments.
Start Free Trial
Learn from the best

Network and collaborate with thousands of CTOs, CISOs, and IT Pros rooting for you and your success.

Andrew Hancock - VMware vExpert
See if this solution works for you by signing up for a 7 day free trial.
Unlock 2 Answers and 5 Comments.
Try for 7 days

”The time we save is the biggest benefit of E-E to our team. What could take multiple guys 2 hours or more each to find is accessed in around 15 minutes on Experts Exchange.

-Mike Kapnisakis, Warner Bros