Full Version: Hiding Auto Number text
UtterAccess Forums > Microsoft® Access > Access Forms
Al3x
Hello all its me again, is there a way to hide (Auto Number) appearing in textboxes? i just want the number to appear not the text autonumber.
Cheers
Jack Cowley
In design view click on the text box in question and if the property sheet is not open then open it. Under the Format tab set the Visible property to No.
th,
Jack
Al3x
that just hides the whole text box, i dont want to hide it, all i want to do is hide the text but i want to view the number
Jack Cowley
Hmmm. Not sure what your data looks like but this function will remove everything an any position in the string and return only the numbers:
CODE
Function RemoveAlphas (ByVal AlphaNum as Variant)
   Dim Clean As String
   Dim Pos, A_Char$
   Pos = 1
   If IsNull(AlphaNum) Then Exit Function
   For Pos = 1 To Len(AlphaNum)
      A_Char$ = Mid(AlphaNum, Pos, 1)
      If A_Char$ >= "0" And A_Char$ <= "9" Then
         Clean$ = Clean$ + A_Char$
      End If
   Next Pos
   RemoveAlphas = Clean$
End Function

hth,
Jack
Al3x
all i am using is the type Autonumber on a textfield so the numbers can be 1 - 999999999....
When i load up a form the words (Auto Number) appear in the field but when you click on another field the words (Auto Number) changes to a number for example 1024. All i want is some way of removing auto number and just hav the number which appears.
R. Hicks
Hmmmmm .....

Use the following example in the Control Source of the txtbox on the form that displays the Autonumber value.
CODE
=IIf(IsNumeric([FieldName]),[FieldName],"")

Change "FieldName" to the actual name of your Autonumber field ...

RDH
Jack Cowley
An autonumber if is a field unto itself and is neither Text nor a Number. When you are in a new record an autonumber is not assigned by Access until you make an entry into one of the controls on the form. 'Autonumber' will always show in your Autonumber control when you are in a new record. If you want to hide that control then try code like this in the On Current event.
If Me.NewRecord Then
Me.NameOfAutonumberControl.Visible = False
Else
Me.NameOfAutonumberControl.Visible = True
End If
Also, in the future you will save everyone time if you will give as much information in your first post as you can rather than over the course of 2 or 3 posts...
hth,
Jack
Jack Cowley
Nice catch Ricky...as usual! I knew there had to be an easier way... Thanks for jumping in!
ack
R. Hicks
Hmmm ...
Try what I posted ...
RDH
R. Hicks
No problem .. frown.gif
DH
Al3x
Hi Jack i tried the code and it removes the whole textfield. Its because you are setting the box to visible = false when it opens (when it opens the record will be new as default) and if the record isnt new the autonumber will appear.
Jack Cowley
Use the code suppled by Mr. Hicks as it should do what you want...
th,
Jack
Al3x
yes it would work but now the problem i have is the form i am using takes data from many tables. So i have tblwhatever.salesnumber
If i insert tblwhatever.salesnumber into fieldname it doesnt work at all.
if a had a single form based of one table it would work fine.
Jack Cowley
Things are getting more complex with each post and my problem is that I have to leave for the day. Hopefully Mr. Hicks is still around and can assist you. You can reply to one of his posts and see if he will be able to help you....
orry...
Jack
Al3x
hmm one way of doing it is to make another textfield and make it equal the auto number and use mr hicks code to remove the autonumber text but its a rather messy way of doing things.
R. Hicks
If the name of the Autonumber field is "salesnumber" .. then use this in the Control Source of the txtbox:
CODE
=IIf(IsNumeric([salesnumber]), [salesnumber], "")

RDH
Al3x
my control source is tblSales.SalesNumber if i stick this in it wont work, i get invalid source
R. Hicks
Is the Autonumber field in the forms recordset ???

If not .. why in the world do you want to see this on the current form ???
Is this value from a subform on the current form ???
Also ... what does this value represent ???

RDH
Al3x
no in this case i didnt use a subform i just made the form source equal two tables. hence the tblSales.SalesNumber
R. Hicks
So this means the recordsource for the form is a query based on 2 tables ???
If yes .. then the autonumber field should be included in this query ...
DH
Al3x
autonumber field is included. but it appears as tblSales.SalesNumber in the table field list
R. Hicks
Then you must have a field named "SalesNumber" in both tables .. and have included both in the query.
Assign an alias name to on of the fields to make it unique:
DH
This is a "lo-fi" version of UA. To view the full version with more information, formatting and images, please click here.