Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Just like "IsNumeric" is there an "IsText" cmd ? 1

Status
Not open for further replies.

testkitt2

Technical User
Apr 28, 2004
193
US
Hello to all
I have a DB at work that tracks tire positions on our trucks by a number stamped on the tire. The code below works like this if the current location is a truck number then a small form pops up with a diagram of the front and rear of a truck (by textboxes) allowing you to go into the corresponding textbox and removing the tire number of the truck. Some tires are in the inventory room. So when the "Location" textbox is change to "inv_room", that pop up does not need to open (maybe a msgbox saying this is not a truck).

Note: when changing the info in the "location" textbox from lets say...an example from trk# 300791 to Inv, the popup box should come up linking the truck number so that the position can be changed.


Code:
Private Sub Location_AfterUpdate()
Dim stDocName As String
 Dim answer As Integer
    Dim stLinkCriteria As String
If IsNumeric(Me![Location]) Then

answer = MsgBox(" Do You Want To Add or Remove Tire Positions ? !", vbQuestion + vbYesNo, "DB Admin")
    If answer = vbNo Then
    Exit Sub
    Else
    stDocName = "FrmTirePosition"
    If IsNumeric(Me![Location]) Then
    stLinkCriteria = "[Fleet Number]=" & "'" & Me![Location] & "'"
    DoCmd.OpenForm stDocName, , , stLinkCriteria
   End If
    End If
    End If
End Sub

Any help is appreciated.
JZ

Testkitt2
 
Hi, Testkitt2,

How about [red]Not[/red] IsNumeric?

Ken S.
 
Or perhaps an "Else" clause in your If..Then statement?

Ken S.
 
To clarify... an Else clause in your If..Then statements which contain the tests for IsNumeric...

Ken S.
 
Hello,
Thanks for your suggestions.
I will try them all and post results.
Thanks
JZ

Testkitt2
 
Hello again,
I tried the "Else" with the "Not IsNumeric" and that solve the first part of my thread.

But here's what I need to add...

In the "Textbox" called "Location" is where the data changes and the added "Else" works great. Now lets say that the current info in "location" is trk# "300791" (just numeric) and I change it to "inventory" then the popup form I mentioned earlier should popup (linked Criteria) so that the popup form can be edited.

Hope this makes sense.
Thanks
JZ


Thanks to all...

Testkitt2
 
Hello,
I pasted the code I'm trying to work with. It only does part of what I want it to do.
The problem I'm having is when there is a trk number already in the "Location" textbox and then changed to non numeric the popup box should come up with the old value (the trk number) so that I can change or remove the info from the popup box for that truck.


Code:
Private Sub Location_AfterUpdate()
'After updating location text box, this commands triggers the FrmTire_Position in db.
 
Dim stDocName As String
 Dim answer As Integer
    Dim stLinkCriteria As String
    If IsNumeric(Me![Location]) Then

answer = MsgBox(" Do You Want To Add or Remove Tire Positions ? !", vbQuestion + vbYesNo, "DB Admin")
    If answer = vbNo Then
    Exit Sub
    Else
    If Not IsNumeric(Me![Location]) And IsNumeric(Me![Location].OldValue) Then
    
     stDocName = "FrmTirePosition"
     stLinkCriteria = "[Fleet Number]=" & "'" & Me![Location].OldValue & "'"
    DoCmd.OpenForm stDocName, , , stLinkCriteria
    
    Exit Sub
    Else
    stDocName = "FrmTirePosition"
    If IsNumeric(Me![Location]) Then
    stLinkCriteria = "[Fleet Number]=" & "'" & Me![Location] & "'"
    DoCmd.OpenForm stDocName, , , stLinkCriteria
   End If
    End If
    End If
    End If
End sub
[\code]
thanks to all
JZ

Testkitt2
 
Have you tried to play with the OldValue property of the Location object ?

Hope This Helps, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884 or FAQ181-2886
 

Good Eve,
Thanks for the suggestion PHV, I'm not sure but I'll give it a try..
Thank you
JZ

Testkitt2
 

Hello to all

I've been trying to insert the OldValue property inside of the code above that PHV suggested but to no avail. PHV can you or someone out there help with this ?

Have you tried to play with the OldValue property of the Location object ? [\quote]

Thanks for your help
JZ

Testkitt2
 
Just throwing my two cents in...
Could you find the first character and test for string?

Sub Findtext()
' 97 - 122 (a - z)
Dim x
Dim y

y = Asc(Me![Location]))
Debug.Print y
End Sub

this returns a number where 97-122 is A-Z.
Hope it helps.
 
Hello to all

I still need help on this thread if anyone can, it will save me
a lot of time at the job...

The main form is called frmTireCertificate, the popup form is called frmTirePosition.

on the main form there is a textbox called txtlocation. In txtlocation you can enter a six digit truck number or a place where the tire is...like inventory. Ok if you open the database and look at txtlocation..it's either numeric or text. What I have now is that if the txtlocation changes from one truck to another or from inventory to a truck the popup form called frmTirePositions will come up for editing. What I want to do is add another feature to this code and make it remember the previous entry in txtlocation only if you are changing the txtlocation from a number to inventory. The purpose of this is so that the popup form can launch for editing.

Note: If you enter in txtlocation from inventory to Joes flat fix the popup box should not come up because neither location has a tire position ..only trucks do.

Thanks again


Main form

frmTireCertificate
txtlocation

Popup form

frmTirePosition
txtFleet_Number

JZ

Testkitt2
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top