Select Case Statement with values based on another fields value.

R

Rob M.

Hi I'm new at VB. I want to write code with a Select case Statement that
would validate data to be entered on a field lngAccountNum that would have
an account number range i.e 1000 to 1999 if The txtAccountType field =
"Asset", "Liability" would be "2000 to 2999, "Equity" "3000 to 3999" and so
on.

I don't know how to build an event . Is it a function, I believe so?

Private Function AcctNum Before Update (Cancel As Integer)

Account is an integer in my Data type field. I'm not sure if it will work.

I have an idea about the code.

The first part I'm not sure about Function or sub or before update?

Dim txtAcctType As String
Dim lngAccountNum As Long

ErrorHandler here

Select Case "Asset"
lngAccount=Between 999 and 2000

Select case "Liability"
lngAccountNum=Between 1999 and 3000

etc


Case Else

End select

End Function?

Thanks for your help, if you understand me, sorry.
 
R

Rob M.

I should have mentioned that the field txtAcctName is locked. I'm not sure
if that makes a difference. I would need the focus on the AcctNum field
since that is where the account number will be stored if possible.

This is a postscipt to the question.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top