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 biv343 on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

DMAX ignore letter in incriments 2

Status
Not open for further replies.

jmbcreative

Technical User
Jan 30, 2006
58
US
Howdy Folks,

I have a bit of a complication with the DMAX sequence that I am running. To give you the rundown, basically I have a table that maintains equipment inventory "HardwareList copy". This table identifies a main system and all of it's components. The are identified with controlID's that go somewhat like
112,
112a,
112b,
113,
113a
..and so on. The plain numbers are the main systems and the numbers with a letter at the end are ethe cooresponding components. I have created a seperate table to hold the new hardware add requests. I have a form to do this to make it easier on the requestor. I created a macro to run when the form loades that asks if the requestor qishes to add a component or a system. If the requestor selects to add a new system, the macro looks at the last controlID in the main hardware inventory and the request table, "HardwareAdd Query", and is supposed to auto incriment and add this number to the field in the hardware add form. This works fine if the last controlID in the hardware inventory is a plain number, but when the last controlID is number witha letter at the end I recieve a "type mismatch error" on load of the form. Does any one know the best way to remedy this so the macro will ingore the letter in the hardware inventory?

Below is the sntax that I am using for this:
_______________________________________________

Private Sub Form_Load()
On Error GoTo Err_Form_Load
Dim reqMsg As Integer
reqMsg = MsgBox("Add New System: Press YES, ADD Component: Press NO", vbYesNoCancel + vbExclamation, "Test Message")
If reqMsg = 6 Then
Dim strMax2
strMax2 = IIf(DMax("[ControlID]", "[HardwareList Copy]") > DMax("[ControlID]", "[HardwareAdd Query]"), 1 + DMax("[ControlID]", "[HardwareList Copy]"), 1 + DMax("[ControlID]", "[HardwareAdd Query]"))
Me.ControlID = CStr(Val(strMax2))

________________________________________

I've been banging my head on this one. Any ideas?
 
What about this ?
strMax2 = IIf(DMax("[ControlID]", "[HardwareList Copy]") > DMax("[ControlID]", "[HardwareAdd Query]"), 1 + [!]Val([/!]DMax("[ControlID]", "[HardwareList Copy]")[!])[/!], 1 + [!]Val([/!]DMax("[ControlID]", "[HardwareAdd Query]")[!])[/!])

A shorter way:
strMax2 = 1 + Val(DMax("ControlID", IIf(DMax("ControlID", "[HardwareList Copy]") > DMax("ControlID", "[HardwareAdd Query]"), "[HardwareList Copy]", "[HardwareAdd Query]")))

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

It worked out. I suppose it make sense perfect sense now that i llok at the solution, just needed someone to point it out.

Many Thanks amigo!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top