Group:  Microsoft Access ยป microsoft.public.access.formscoding
Thread: Update Form Field from another Form

Geek News

Update Form Field from another Form
dbarmer 11/13/2008 7:40:01 PM
There are probably serveral ways this can be done, however I am having
trouble with them all.

I have a form with preloaded data that can be edited. However, if the data
needs to be changed, then the user should be able to pick the correct
[Employee] in this case.

The field itslef cannot be a lookup because it's tied to a table that is NOT
a lookup field - Nor should it be.

So, I have a command button called "Change Employee Name" where if clicked
will open another form, allowing the user to select an employee in a drop
down box.

Through VBA code, I was trying to update the main form with the new data on
the second open form. I cannot get this to work. There are two fileds on
the main form that need to be updated (an Employee and Employee No)

What is the BEST way to do this? I have come so close to geting it to work,
however it is not quite there. I need a fresh approach.

Can someone help?
Re: Update Form Field from another Form
"tkelley via AccessMonster.com" <u47368[ at ]uwe> 11/13/2008 7:59:32 PM
I assume the EmployeeNo is either in your dropdown as another column, or
somewhere on the [ChangeEmployeeName] form. If my assumption is correct, in
the on click event of your [Apply Changes] button on the [ChangeEmployeeName]
form:

Separate fields:
Forms!frmTargetForm![EmployeeName.value = me.EmployeeName
Forms!frmTargetForm![EmployeeNo.value = me.EmployeeNo

Columns in your dropdown:
'where EmployeeName is the first column
Forms!frmTargetForm![EmployeeName.value = me.cmbEmployee.column(0,0)

'where EmployeeNo is the second column
Forms!frmTargetForm![EmployeeNo.value = me.cmbEmployee.column(0,1)



dbarmer wrote:
[Quoted Text]
>There are probably serveral ways this can be done, however I am having
>trouble with them all.
>
>I have a form with preloaded data that can be edited. However, if the data
>needs to be changed, then the user should be able to pick the correct
>[Employee] in this case.
>
>The field itslef cannot be a lookup because it's tied to a table that is NOT
>a lookup field - Nor should it be.
>
>So, I have a command button called "Change Employee Name" where if clicked
>will open another form, allowing the user to select an employee in a drop
>down box.
>
>Through VBA code, I was trying to update the main form with the new data on
>the second open form. I cannot get this to work. There are two fileds on
>the main form that need to be updated (an Employee and Employee No)
>
>What is the BEST way to do this? I have come so close to geting it to work,
>however it is not quite there. I need a fresh approach.
>
>Can someone help?

--
Message posted via AccessMonster.com
http://www.accessmonster.com/Uwe/Forums.aspx/access-formscoding/200811/1

Re: Update Form Field from another Form
"tkelley via AccessMonster.com" <u47368[ at ]uwe> 11/13/2008 8:00:13 PM
I left off the closing bracket ... see below for change

tkelley wrote:
[Quoted Text]
>I assume the EmployeeNo is either in your dropdown as another column, or
>somewhere on the [ChangeEmployeeName] form. If my assumption is correct, in
>the on click event of your [Apply Changes] button on the [ChangeEmployeeName]
>form:
>
>Separate fields:
>Forms!frmTargetForm![EmployeeName].value = me.EmployeeName
>Forms!frmTargetForm![EmployeeNo].value = me.EmployeeNo
>
>Columns in your dropdown:
>'where EmployeeName is the first column
>Forms!frmTargetForm![EmployeeName.value = me.cmbEmployee.column(0,0)
>
>'where EmployeeNo is the second column
>Forms!frmTargetForm![EmployeeNo.value = me.cmbEmployee.column(0,1)
>
>>There are probably serveral ways this can be done, however I am having
>>trouble with them all.
>[quoted text clipped - 18 lines]
>>
>>Can someone help?

--
Message posted via AccessMonster.com
http://www.accessmonster.com/Uwe/Forums.aspx/access-formscoding/200811/1

Re: Update Form Field from another Form
"tkelley via AccessMonster.com" <u47368[ at ]uwe> 11/13/2008 8:01:43 PM
Okay, sorry ... guess seeing below doesn't work: So here it is again, even
though you probably knew what I was talking about:

Separate fields:
Forms!frmTargetForm![EmployeeName].value = me.EmployeeName
Forms!frmTargetForm![EmployeeNo].value = me.EmployeeNo

Columns in your dropdown:
'where EmployeeName is the first column
Forms!frmTargetForm![EmployeeName].value = me.cmbEmployee.column(0,0)

'where EmployeeNo is the second column
Forms!frmTargetForm![EmployeeNo].value = me.cmbEmployee.column(0,1)

tkelley wrote:
[Quoted Text]
>I left off the closing bracket ... see below for change
>
>>I assume the EmployeeNo is either in your dropdown as another column, or
>>somewhere on the [ChangeEmployeeName] form. If my assumption is correct, in
>[quoted text clipped - 17 lines]
>>>
>>>Can someone help?

--
Message posted via http://www.accessmonster.com

Re: Update Form Field from another Form
"Mike Painter" <mddotpainter[ at ]sbcglobal.net> 11/13/2008 9:06:41 PM
dbarmer wrote:
[Quoted Text]
> There are probably serveral ways this can be done, however I am having
> trouble with them all.
>
> I have a form with preloaded data that can be edited. However, if
> the data needs to be changed, then the user should be able to pick
> the correct [Employee] in this case.
>
> The field itslef cannot be a lookup because it's tied to a table that
> is NOT a lookup field - Nor should it be.
>
> So, I have a command button called "Change Employee Name" where if
> clicked will open another form, allowing the user to select an
> employee in a drop down box.
>
> Through VBA code, I was trying to update the main form with the new
> data on the second open form. I cannot get this to work. There are
> two fileds on the main form that need to be updated (an Employee and
> Employee No)
>
> What is the BEST way to do this? I have come so close to geting it
> to work, however it is not quite there. I need a fresh approach.
>
> Can someone help?

It sounds like you are keeping information in two places. This is almost
always a mistake.
If not then refreshing the form after making the changes will reload the new
information.
Using a modal form for the change makes this easier.


Re: Update Form Field from another Form
"Klatuu" <david.hargis[ at ]realpage.com> 11/13/2008 9:08:45 PM
You are correct, it should not be a lookup field. Nothing should ever be.
It is really quite simple. Rather than a text box for the employee, change
it to a combo box and base the combo box's row source on the employee table.
When you select an employee, it will insert the employee's name in the
form's record source.

"dbarmer" <dbarmer[ at ]discussions.microsoft.com> wrote in message
news:6C52CFF0-B54D-4887-BFE2-21462916DE9C[ at ]microsoft.com...
[Quoted Text]
> There are probably serveral ways this can be done, however I am having
> trouble with them all.
>
> I have a form with preloaded data that can be edited. However, if the
> data
> needs to be changed, then the user should be able to pick the correct
> [Employee] in this case.
>
> The field itslef cannot be a lookup because it's tied to a table that is
> NOT
> a lookup field - Nor should it be.
>
> So, I have a command button called "Change Employee Name" where if clicked
> will open another form, allowing the user to select an employee in a drop
> down box.
>
> Through VBA code, I was trying to update the main form with the new data
> on
> the second open form. I cannot get this to work. There are two fileds on
> the main form that need to be updated (an Employee and Employee No)
>
> What is the BEST way to do this? I have come so close to geting it to
> work,
> however it is not quite there. I need a fresh approach.
>
> Can someone help?


Re: Update Form Field from another Form
"tkelley via AccessMonster.com" <u47368[ at ]uwe> 11/13/2008 9:13:35 PM
I agree if the information is being kept in two different tables. I didn't
understand that to be the case.

Mike Painter wrote:
[Quoted Text]
>> There are probably serveral ways this can be done, however I am having
>> trouble with them all.
>[quoted text clipped - 19 lines]
>>
>> Can someone help?
>
>It sounds like you are keeping information in two places. This is almost
>always a mistake.
>If not then refreshing the form after making the changes will reload the new
>information.
>Using a modal form for the change makes this easier.

--
Message posted via http://www.accessmonster.com

Re: Update Form Field from another Form
dbarmer 11/13/2008 9:14:27 PM
Thanks tkelley! It was the .Value that made the difference. NOW, I think
we are almost there. The problem now it, is changes the field to the last
time a user changed employee. So If I close everthing out and re-open, then
choose Change Employee, it is correct then - some kind of refresh problem.
I've tried Me.Refresh. Any ideas? These forms are offically on my last
nerve.

"tkelley via AccessMonster.com" wrote:

[Quoted Text]
> I assume the EmployeeNo is either in your dropdown as another column, or
> somewhere on the [ChangeEmployeeName] form. If my assumption is correct, in
> the on click event of your [Apply Changes] button on the [ChangeEmployeeName]
> form:
>
> Separate fields:
> Forms!frmTargetForm![EmployeeName.value = me.EmployeeName
> Forms!frmTargetForm![EmployeeNo.value = me.EmployeeNo
>
> Columns in your dropdown:
> 'where EmployeeName is the first column
> Forms!frmTargetForm![EmployeeName.value = me.cmbEmployee.column(0,0)
>
> 'where EmployeeNo is the second column
> Forms!frmTargetForm![EmployeeNo.value = me.cmbEmployee.column(0,1)
>
>
>
> dbarmer wrote:
> >There are probably serveral ways this can be done, however I am having
> >trouble with them all.
> >
> >I have a form with preloaded data that can be edited. However, if the data
> >needs to be changed, then the user should be able to pick the correct
> >[Employee] in this case.
> >
> >The field itslef cannot be a lookup because it's tied to a table that is NOT
> >a lookup field - Nor should it be.
> >
> >So, I have a command button called "Change Employee Name" where if clicked
> >will open another form, allowing the user to select an employee in a drop
> >down box.
> >
> >Through VBA code, I was trying to update the main form with the new data on
> >the second open form. I cannot get this to work. There are two fileds on
> >the main form that need to be updated (an Employee and Employee No)
> >
> >What is the BEST way to do this? I have come so close to geting it to work,
> >however it is not quite there. I need a fresh approach.
> >
> >Can someone help?
>
> --
> Message posted via AccessMonster.com
> http://www.accessmonster.com/Uwe/Forums.aspx/access-formscoding/200811/1
>
>
Re: Update Form Field from another Form
dbarmer 11/13/2008 9:24:18 PM
This is complicated - The data being in two places - The master tables are
from ODBC - using another program - I have no choice at this point. The
..Value Option worked - almost. There is a refresh problem. see my other
post. Any ideas?

"tkelley via AccessMonster.com" wrote:

[Quoted Text]
> I agree if the information is being kept in two different tables. I didn't
> understand that to be the case.
>
> Mike Painter wrote:
> >> There are probably serveral ways this can be done, however I am having
> >> trouble with them all.
> >[quoted text clipped - 19 lines]
> >>
> >> Can someone help?
> >
> >It sounds like you are keeping information in two places. This is almost
> >always a mistake.
> >If not then refreshing the form after making the changes will reload the new
> >information.
> >Using a modal form for the change makes this easier.
>
> --
> Message posted via http://www.accessmonster.com
>
>
Re: Update Form Field from another Form
"tkelley via AccessMonster.com" <u47368[ at ]uwe> 11/13/2008 9:29:08 PM
No ... it shouldn't need anything more. It should just change it to what you
told it to. I'm missing something. Perhaps because I usually deal with
disconnected forms and perform my updates with SQL.

Read: Klatuu - 11-13-2008 15:08 It could be as simple as just using a
combo box. Your table field doesn't have to be a lookup in order to use a
combo box. I never call fields lookup; but I use combo boxes and list boxes
all the time.

dbarmer wrote:
[Quoted Text]
>Thanks tkelley! It was the .Value that made the difference. NOW, I think
>we are almost there. The problem now it, is changes the field to the last
>time a user changed employee. So If I close everthing out and re-open, then
>choose Change Employee, it is correct then - some kind of refresh problem.
>I've tried Me.Refresh. Any ideas? These forms are offically on my last
>nerve.
>
>> I assume the EmployeeNo is either in your dropdown as another column, or
>> somewhere on the [ChangeEmployeeName] form. If my assumption is correct, in
>[quoted text clipped - 34 lines]
>> >
>> >Can someone help?

--
Message posted via http://www.accessmonster.com

Re: Update Form Field from another Form
dbarmer 11/13/2008 9:41:04 PM
Thanks - Klatuu! You were right, it was simple - I was trying to make it
really complicated. The Combox Box allowed me to create a sql querry to the
ODBC table with the needed field name!

GEEZ! Sometimes simple is the best, Thanks Again!!


"Klatuu" wrote:

[Quoted Text]
> You are correct, it should not be a lookup field. Nothing should ever be.
> It is really quite simple. Rather than a text box for the employee, change
> it to a combo box and base the combo box's row source on the employee table.
> When you select an employee, it will insert the employee's name in the
> form's record source.
>
> "dbarmer" <dbarmer[ at ]discussions.microsoft.com> wrote in message
> news:6C52CFF0-B54D-4887-BFE2-21462916DE9C[ at ]microsoft.com...
> > There are probably serveral ways this can be done, however I am having
> > trouble with them all.
> >
> > I have a form with preloaded data that can be edited. However, if the
> > data
> > needs to be changed, then the user should be able to pick the correct
> > [Employee] in this case.
> >
> > The field itslef cannot be a lookup because it's tied to a table that is
> > NOT
> > a lookup field - Nor should it be.
> >
> > So, I have a command button called "Change Employee Name" where if clicked
> > will open another form, allowing the user to select an employee in a drop
> > down box.
> >
> > Through VBA code, I was trying to update the main form with the new data
> > on
> > the second open form. I cannot get this to work. There are two fileds on
> > the main form that need to be updated (an Employee and Employee No)
> >
> > What is the BEST way to do this? I have come so close to geting it to
> > work,
> > however it is not quite there. I need a fresh approach.
> >
> > Can someone help?
>
>
>
Re: Update Form Field from another Form
"Klatuu" <david.hargis[ at ]realpage.com> 11/14/2008 3:37:40 PM
The .Value has nothing to do with it.
It is the default property returned when you refer to a control.

"dbarmer" <dbarmer[ at ]discussions.microsoft.com> wrote in message
news:3208CBD5-F795-4A59-9E25-BEA2AC026931[ at ]microsoft.com...
[Quoted Text]
> Thanks tkelley! It was the .Value that made the difference. NOW, I
> think
> we are almost there. The problem now it, is changes the field to the last
> time a user changed employee. So If I close everthing out and re-open,
> then
> choose Change Employee, it is correct then - some kind of refresh problem.
> I've tried Me.Refresh. Any ideas? These forms are offically on my last
> nerve.
>
> "tkelley via AccessMonster.com" wrote:
>
>> I assume the EmployeeNo is either in your dropdown as another column, or
>> somewhere on the [ChangeEmployeeName] form. If my assumption is correct,
>> in
>> the on click event of your [Apply Changes] button on the
>> [ChangeEmployeeName]
>> form:
>>
>> Separate fields:
>> Forms!frmTargetForm![EmployeeName.value = me.EmployeeName
>> Forms!frmTargetForm![EmployeeNo.value = me.EmployeeNo
>>
>> Columns in your dropdown:
>> 'where EmployeeName is the first column
>> Forms!frmTargetForm![EmployeeName.value = me.cmbEmployee.column(0,0)
>>
>> 'where EmployeeNo is the second column
>> Forms!frmTargetForm![EmployeeNo.value = me.cmbEmployee.column(0,1)
>>
>>
>>
>> dbarmer wrote:
>> >There are probably serveral ways this can be done, however I am having
>> >trouble with them all.
>> >
>> >I have a form with preloaded data that can be edited. However, if the
>> >data
>> >needs to be changed, then the user should be able to pick the correct
>> >[Employee] in this case.
>> >
>> >The field itslef cannot be a lookup because it's tied to a table that is
>> >NOT
>> >a lookup field - Nor should it be.
>> >
>> >So, I have a command button called "Change Employee Name" where if
>> >clicked
>> >will open another form, allowing the user to select an employee in a
>> >drop
>> >down box.
>> >
>> >Through VBA code, I was trying to update the main form with the new data
>> >on
>> >the second open form. I cannot get this to work. There are two fileds
>> >on
>> >the main form that need to be updated (an Employee and Employee No)
>> >
>> >What is the BEST way to do this? I have come so close to geting it to
>> >work,
>> >however it is not quite there. I need a fresh approach.
>> >
>> >Can someone help?
>>
>> --
>> Message posted via AccessMonster.com
>> http://www.accessmonster.com/Uwe/Forums.aspx/access-formscoding/200811/1
>>
>>


Home | Search | Terms | Imprint Contact
Newsgroups Reader - provided by WiredBox.Net