Hi Ron,
Okay, start by creating a new module in your database. Click on the Modules
tab, and then click on the New button. You should see a new code module
opened up, with two lines of code:
Option Compare Database
Option Explicit
If you do not see Option Explicit, then add this line of code manually. Then
click on Tools > Options while in the VBA Editor and place a check in
"Require Variable Declaration", so that you will get these two *very
important* words inserted into all new modules. For more information, please
see this link:
Always Use Option Explicit
http://www.access.qbuilt.com/html/gem_tips.html#VBEOptions
Now copy and paste the following function shown below into your new module.
Save the module as basDetermineCustType. Then click on Debug > Compile
ProjectName. Hopefully, you will not get any compile errors (you may uncover
compile errors in other code modules, however, if you are not compiling any
new/edited code regularly). Add the following to the Field row of your
query, to call your new function:
Customer Type: DetermineCustType([CPARTY],[TNUM])
Here is the function. Note that the URL shown as a reference will be
wrapped. You'll need to make this URL on one line:
'**************Begin Code**************************
' Written just for Ron by Tom Wickerath, 7/24/2006
'
http://www.microsoft.com/office/community/en-us/default.mspx?
dg=microsoft.public.access&mid=99251f5c-3aa4-4481-b345-d017b4d29cff
Function DetermineCustType _
(CPARTY As Variant, TNUM As Variant) As String
If IsNull(CPARTY + TNUM) Then
DetermineCustType = "Unknown"
Exit Function
End If
Select Case Left$(CPARTY, 1)
Case "1"
Select Case (TNUM)
Case "0", "1"
DetermineCustType = "BANKSPOT"
Case "FW"
DetermineCustType = "BANKFORWARD"
Case Else
DetermineCustType = "Unknown"
End Select
Case "2"
Select Case (TNUM)
Case "0", "1"
DetermineCustType = "CUSTOMERSPOT"
Case "FW"
DetermineCustType = "CUSTOMERFORWARD"
Case Else
DetermineCustType = "Unknown"
End Select
Case Else
DetermineCustType = "Unknown"
End Select
End Function
'**************End Code**************************
Tom Wickerath
Microsoft Access MVP
http://www.access.qbuilt.com/html/expert_contributors.html
http://www.access.qbuilt.com/html/search.html
__________________________________________
Rony said:
Hi Tom
it is very nice of to guide me via VB, thanks a lot.
Actuall i get the data download from a live system and i trying to classify
through query and no input is involved . Any how when u find time if you can
guide me through VB it can help me to incorporate the VB proc in some other
programme.
Thanks