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

Populate value 1

Status
Not open for further replies.

qwerty70

Technical User
Dec 13, 2005
73
GB
Dear All,

My frmDrawing is bound to a table called tblDrawing. frmDrawing have 2 fields, txtDwgNum and txtDescription. txtDwgNum is indexed and accepts duplicate entry. What I would like to happen is, if I enter any drawing number that is already existing in the tblDrawing, I want the Description to be automatically populated in my form. This is to save my time re-typing the whole description again. But if the drawing number does not exist, then I of course I need to type it.

Your help is highly appreciated.

qwerty70
 
How are ya qwerty70 . . .

There's a big question here as far as your table structure is concerned (the same prompted [blue]PHV's post![/blue]).

In any case [blue]DLookup[/blue] should help. Copy/paste the following in the [blue]AfterUpdate[/blue] event of txtDwgNum:
Code:
[blue]   Dim Ans As String, Cri As String
   
   Cri = "[txtDwgNum] = [red][b]'[/b][/red]" & Me![txtDwgNum] & "[red][b]'[/b][/red]"
   Ans = Nz(DLookup("[txtDescription]", "tblDrawing", Cri), "")
   If Ans <> "" Then Me!txtDescription = Ans[/blue]
If txtDwgNum is numeric, remove the two single quotes in [red]red[/red] . . .

Calvin.gif
See Ya! . . . . . .

Be sure to see thread181-473997
Also faq181-2886
 
TheAceman1, thanks a lot. That's exactly what I'm looking for.

reqards,

qwerty70
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top