473,383 Members | 1,859 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,383 software developers and data experts.

Code to look for and match a text string in a field

15
Hi,

In a new record in a "Jobs" table, I enter the "ClaimantID" (the person who this job involves) but I want to know whether or not this particular Claimant has had jobs done on them previously, and if so, who the person responsible for working on that job was (found in a separate field called "PI").

Can I write code that asks the database to:
- search for and match a ClaimantID that I type in a text box in a form
- output who the PI (found in a different field) that worked on that previous job was
- sometimes a claimant might have several previous jobs

I will pay $50(au) to anyone's BSB account if they help me with this code. I have been working on this for too long and I am over it. I am not a programmer but have been forced into a situation where I need some code because Access is not capable of such a function without it.

deejow
Aug 7 '07 #1
2 1656
barry07
47
I do this sort of thing quite often using the Dlookup function. Here's a sample that should work for you - I've used Message boxes to return the result of the lookup but obviously you can change this to call whatever process is appropriate in your case. If you want to determine the number of previous records for this claimant you can use Dcount with the same syntax.

Using nz forces the return of a null string in the event the lookup fails and prevents the code falling over.

<Code(vb)>
Sub txtClaimID_AfterUpdate
Dim sPI as string
sPI=nz(Dlookup("PI","Jobs","ClaimantID='" & txtClaimID &"'"),"")
IF sPI>"" then
Msgbox "Previous PI=" & sPI & " for this claimant"
Else
Msgbox "No previous record for this claimant"
End if
End Sub
</Code>
Aug 7 '07 #2
deejow
15
I do this sort of thing quite often using the Dlookup function. Here's a sample that should work for you - I've used Message boxes to return the result of the lookup but obviously you can change this to call whatever process is appropriate in your case. If you want to determine the number of previous records for this claimant you can use Dcount with the same syntax.

Using nz forces the return of a null string in the event the lookup fails and prevents the code falling over.

<Code(vb)>
Sub txtClaimID_AfterUpdate
Dim sPI as string
sPI=nz(Dlookup("PI","Jobs","ClaimantID='" & txtClaimID &"'"),"")
IF sPI>"" then
Msgbox "Previous PI=" & sPI & " for this claimant"
Else
Msgbox "No previous record for this claimant"
End if
End Sub
</Code>
Thnx for reply. What is the Access equivalent for this code and where do I put it?

deejow
Aug 10 '07 #3

Sign in to post your reply or Sign up for a free account.

Similar topics

2
by: rked | last post by:
I get nameSPAN1 is undefined when I place cursor in comments box.. <%@ LANGUAGE="VBScript" %> <% DIM ipAddress ipAddress=Request.Servervariables("REMOTE_HOST") %> <html> <head> <meta...
3
by: Andy | last post by:
Hi all, I'm having a problem doing an Xslt transform in code. I've done it before, so I'm not really sure why its not working. The problem is that the result of the transform is an empty...
8
by: ShyGuy | last post by:
Is it possible to use code to enter some text into a combo box and then have the cursor placed at the end of the text for more imput?
29
by: zoro | last post by:
Hi, I am new to C#, coming from Delphi. In Delphi, I am using a 3rd party string handling library that includes some very useful string functions, in particular I'm interested in BEFORE (return...
11
by: Keith | last post by:
I apologize for those of you who think I'm posting on the same topic. It is not that I don't appreciate all of your comments - and I'm definitely reading them all - but I think I have a differing...
6
by: TPJ | last post by:
Help me please, because I really don't get it. I think it's some stupid mistake I make, but I just can't find it. I have been thinking about it for three days so far and I still haven't found any...
17
by: Mark | last post by:
I must create a routine that finds tokens in small, arbitrary VB code snippets. For example, it might have to find all occurrences of {Formula} I was thinking that using regular expressions...
4
by: jmdaviault | last post by:
I want to do the equivalent of SELECT id from TABLE WHERE text='text' only fast solution I found is: SELECT id,text from TABLE WHERE MATCH(text) AGAINST('value' IN BOOLEAN MODE) HAVING...
5
by: Ron S | last post by:
After days of searching I finally an example that would work with my application, the only problem is after entering all of the code it is not working. Would someone be kind enough to take a look at...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.