link data fields in a form

  • Thread starter Thread starter Shannon
  • Start date Start date
S

Shannon

How do I link fields of data in a form

For example, i have an entry form for users that i want
everytime the user enters a particular ID for a new form,
the field "City" will automatically enter the City for
that particular field w/out user having to enter.
 
Hi,


Push the data in the after update event of the ID control:


Me.CityName =DLookup("CityName", "tablenameToLookIntoHere",
"CityID=" & Me.IDcontrol)



as example (use the real table, field and control names that suit your
case).




Hoping it may help,
Vanderghast, Access MVP
 
Hi,

I don't quite understand and where the code should go on
my form.

I looked at my entry form and it doesn't have the
onCurrent event
This is what i have for afterupdate
Private Sub List38_AfterUpdate()
' Find the record that matches the control.
Dim rs As Object

Set rs = Me.Recordset.Clone
rs.FindFirst "[WBS] = '" & Me![List38] & "'"
If Not rs.EOF Then Me.Bookmark = rs.Bookmark
End Sub


I'm not sure where your code should go
Thanks
-----Original Message-----
Hi,


Push the data in the after update event of the ID control:


Me.CityName =DLookup
("CityName", "tablenameToLookIntoHere",
 
Hi,


You enter the ID from a List box control? I assume you enter the ID
from a combo box, or from a text edit control. A list box, on the other
hand, does not necessary have ONE value (mainly if multiple selection is
enabled) and it is not "safe" (modification is design) to relay on it for
having one, a, value.

So, still assuming you use the control ID, then


===============
Private Sub ID_AfterUpdate()

Me.CityName = DLookup( .... )

End Sub
===============


Nothing more (at least, not for what is involved here).


I assumed also that the control receiving the City Name is ... CityName.
I didn't retype the whole DLookup syntax. I assume you can get it by
yourself, with the real name you used.



Hoping it may help,
Vanderghast, Access MVP



Shannon said:
Hi,

I don't quite understand and where the code should go on
my form.

I looked at my entry form and it doesn't have the
onCurrent event
This is what i have for afterupdate
Private Sub List38_AfterUpdate()
' Find the record that matches the control.
Dim rs As Object

Set rs = Me.Recordset.Clone
rs.FindFirst "[WBS] = '" & Me![List38] & "'"
If Not rs.EOF Then Me.Bookmark = rs.Bookmark
End Sub


I'm not sure where your code should go
Thanks
-----Original Message-----
Hi,


Push the data in the after update event of the ID control:


Me.CityName =DLookup
("CityName", "tablenameToLookIntoHere",
"CityID=" & Me.IDcontrol)



as example (use the real table, field and control names that suit your
case).




Hoping it may help,
Vanderghast, Access MVP




.
 
Back
Top