dbTalk Databases Forums  

auto-update a feild

comp.databases.ms-access comp.databases.ms-access


Discuss auto-update a feild in the comp.databases.ms-access forum.



Reply
 
Thread Tools Display Modes
  #1  
Old   
Paul
 
Posts: n/a

Default auto-update a feild - 01-22-2009 , 04:47 AM






Hi, I have a table which contains 2 fields, Initials and Full Name.

On my input form I have 2 fields, Initials and Full Name.

I want users to be able to select Initials only and access to populate
the Full Name field automatically on my form.

Thanks

Reply With Quote
  #2  
Old   
Rick Brandt
 
Posts: n/a

Default Re: auto-update a feild - 01-22-2009 , 06:19 AM






On Thu, 22 Jan 2009 02:47:31 -0800, Paul wrote:

Quote:
Hi, I have a table which contains 2 fields, Initials and Full Name.

On my input form I have 2 fields, Initials and Full Name.

I want users to be able to select Initials only and access to populate
the Full Name field automatically on my form.

Thanks
Is your form entering data into the same table or into a different
table? If the former, why are you storing the same person again if they
are already in there? If the latter why copy both fields to the new
table? In that scenario you should be copying only the Primary Key value
from the first table and then using lookup mechanisms to *display* other
data about the person on your form without copying it. Is that what you
are trying to do?

If so, the more common methods are to use Dlookup(), a query for your
form that joins to the other table (this can affect edit-ability of your
form), ComboBoxes with hidden extra columns from which you can pull the
other data and display it in TextBoxes, or subforms.


--
Rick Brandt, Microsoft Access MVP
Email (as appropriate) to...
RBrandt at Hunter dot com


Reply With Quote
  #3  
Old   
Paul
 
Posts: n/a

Default Re: auto-update a feild - 01-22-2009 , 03:09 PM



On Jan 22, 12:19*pm, Rick Brandt <rickbran... (AT) hotmail (DOT) com> wrote:
Quote:
On Thu, 22 Jan 2009 02:47:31 -0800, Paul wrote:
Hi, I have a table which contains 2 fields, Initials and Full Name.

On my input form I have 2 fields, Initials and Full Name.

I want users to be able to select Initials only and access to populate
the Full Name field automatically on my form.

Thanks

Is your form entering data into the same table or into a different
table? *If the former, why are you storing the same person again if they
are already in there? *If the latter why copy both fields to the new
table? *In that scenario you should be copying only the Primary Key value
from the first table and then using lookup mechanisms to *display* other
data about the person on your form without copying it. *Is that what you
are trying to do?

If so, the more common methods are to use Dlookup(), a query for your
form that joins to the other table (this can affect edit-ability of your
form), ComboBoxes with hidden extra columns from which you can pull the
other data and display it in TextBoxes, or subforms.

--
Rick Brandt, Microsoft Access MVP
Email (as appropriate) to...
RBrandt * at * Hunter * dot * com
HI Rick, I am only going to store the Initials in the new table
butwould like to display the full name on the form when a user picks
theInitials. I have tried the Dllookup but can not get it to work.
Thanks


Reply With Quote
  #4  
Old   
Salad
 
Posts: n/a

Default Re: auto-update a feild - 01-22-2009 , 05:03 PM



Paul wrote:

Quote:
On Jan 22, 12:19 pm, Rick Brandt <rickbran... (AT) hotmail (DOT) com> wrote:

On Thu, 22 Jan 2009 02:47:31 -0800, Paul wrote:

Hi, I have a table which contains 2 fields, Initials and Full Name.

On my input form I have 2 fields, Initials and Full Name.

I want users to be able to select Initials only and access to populate
the Full Name field automatically on my form.

Thanks

Is your form entering data into the same table or into a different
table? If the former, why are you storing the same person again if they
are already in there? If the latter why copy both fields to the new
table? In that scenario you should be copying only the Primary Key value
from the first table and then using lookup mechanisms to *display* other
data about the person on your form without copying it. Is that what you
are trying to do?

If so, the more common methods are to use Dlookup(), a query for your
form that joins to the other table (this can affect edit-ability of your
form), ComboBoxes with hidden extra columns from which you can pull the
other data and display it in TextBoxes, or subforms.

--
Rick Brandt, Microsoft Access MVP
Email (as appropriate) to...
RBrandt at Hunter dot com


HI Rick, I am only going to store the Initials in the new table
butwould like to display the full name on the form when a user picks
theInitials. I have tried the Dllookup but can not get it to work.
Thanks
Have you considered a combo box? Using a query you can select the two
tables and link on the init. With it, you could create a multi-column
list. Let's say the first column is the initials and second is the the
name. Then you could put, in the AfterUpdate event, something like
Me.FullName = Me.Combobox.Column(1)
You'd use (1) as it's the second element in the column array.


Reply With Quote
  #5  
Old   
Rick Brandt
 
Posts: n/a

Default Re: auto-update a feild - 01-22-2009 , 06:36 PM



On Thu, 22 Jan 2009 13:09:12 -0800, Paul wrote:

Post the expression for DLookup you used. Should be something like..


=DLookup("FullName", "TableName", "Initials = [InitialsControl]")




--
Rick Brandt, Microsoft Access MVP
Email (as appropriate) to...
RBrandt at Hunter dot com

Reply With Quote
  #6  
Old   
Paul
 
Posts: n/a

Default Re: auto-update a feild - 01-23-2009 , 09:31 AM



On Jan 23, 12:36*am, Rick Brandt <rickbran... (AT) hotmail (DOT) com> wrote:
Quote:
On Thu, 22 Jan 2009 13:09:12 -0800, Paul wrote:

Post the expression for DLookup you used. *Should be something like..

=DLookup("FullName", "TableName", "Initials = [InitialsControl]")

--
Rick Brandt, Microsoft Access MVP
Email (as appropriate) to...
RBrandt * at * Hunter * dot * com
Hi this is what I used

Private Sub Name1_AfterUpdate()
=DLookup("Name", "tblnames", "Initials = [Initials1]")
End Sub


Reply With Quote
  #7  
Old   
bobh
 
Posts: n/a

Default Re: auto-update a feild - 01-23-2009 , 02:38 PM



On Jan 23, 10:31*am, Paul <burnsp... (AT) hotmail (DOT) co.uk> wrote:
Quote:
On Jan 23, 12:36*am, Rick Brandt <rickbran... (AT) hotmail (DOT) com> wrote:

On Thu, 22 Jan 2009 13:09:12 -0800, Paul wrote:

Post the expression for DLookup you used. *Should be something like..

=DLookup("FullName", "TableName", "Initials = [InitialsControl]")

--
Rick Brandt, Microsoft Access MVP
Email (as appropriate) to...
RBrandt * at * Hunter * dot * com

Hi this is what I used

Private Sub Name1_AfterUpdate()
=DLookup("Name", "tblnames", "Initials = [Initials1]")
End Sub
If Initials1 is text then you might need tic marks around it,
I think Dlookup needs to know it's a text value so,

DLookup("Name", "tblnames", "Initials = '" & [Initials1] & "'")

that's a single tic, double tic after the = and
a double tic, single tic, double tic after the [Initials] &
bobh.


Reply With Quote
  #8  
Old   
Rick Brandt
 
Posts: n/a

Default Re: auto-update a feild - 01-24-2009 , 06:56 AM



On Fri, 23 Jan 2009 07:31:03 -0800, Paul wrote:

Quote:
On Jan 23, 12:36Â*am, Rick Brandt <rickbran... (AT) hotmail (DOT) com> wrote:
On Thu, 22 Jan 2009 13:09:12 -0800, Paul wrote:

Post the expression for DLookup you used. Â*Should be something like..

=DLookup("FullName", "TableName", "Initials = [InitialsControl]")

--
Rick Brandt, Microsoft Access MVP
Email (as appropriate) to...
RBrandt Â* at Â* Hunter Â* dot Â* com

Hi this is what I used

Private Sub Name1_AfterUpdate()
=DLookup("Name", "tblnames", "Initials = [Initials1]") End Sub

This does not need to be done in code (and if done in code you do not use
an equals sign at the beginning). Just put it as an expression in the
ControlSource property of the TextBox (where you DO need =).

Also "Name" is a reserved word so that might be causing a problem.
Switch to "FullName" or something else as appropriate.


--
Rick Brandt, Microsoft Access MVP
Email (as appropriate) to...
RBrandt at Hunter dot com


Reply With Quote
Reply




Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off



Powered by vBulletin Version 3.5.3
Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.