PC Review


Reply
Thread Tools Rate Thread

On Close assign a value

 
 
Lori LeRoy
Guest
Posts: n/a
 
      24th May 2010
I would like to assign a value to a field when closing a form. I have three
employees (buyers) that we manually assign records for them to work. I would
like to do this automatically based on the ID# of the record. I have the
idea of what to do, but not sure how to program it.

In my table - tblreqs - I would like to automatically assign a buyer (# 10
or #26 or #29) based on the ReqHeaderID.
On close, if ReqHeader ID ends in 1,4,7, or 0, Buyer = 26; If ReqHeaderID
ends in 2,5,8 Buyer = 29; If ReqHeaderID ends in 3, 6, 9 Buyer - 10.

Can someone tell me how to write this code? Thanks!
 
Reply With Quote
 
 
 
 
Daryl S
Guest
Posts: n/a
 
      24th May 2010
Lori -

You can do this in code - I would suggest in the BeforeUpdate event of the
form. Here is some sample code - you will need to use the right fields for
your case.

Dim ReqHeadIDEnd As String

'if ReqHeadID is a string, then use this:
ReqHeadIDEnd = left(Me.[ReqHeaderID],1)
'if ReqHeadID is numeric, then use this:
ReqHeadIDEnd = Str(modMe.[ReqHeaderID] mod 10)

IF isnull(Me.Buyer) Then 'This will only update the Buyer if it is null, so
it won't over-write any existing buyers.
SELECT Case left(Me.[ReqHeaderID],1)
CASE "1", "4", "7", "0"
Me.Buyer = 26
CASE "2","5","8"
Me.Buyer = 29
CASE "3","6","9"
Me.Buyer = 10
END SELECT
End If

You could also build a "BuyerAssignment" table with the key value to drive
this, and use a query to update the Buyer based on the values in this table
and the right-most integer in the ReqHeaderID.


--
Daryl S


"Lori LeRoy" wrote:

> I would like to assign a value to a field when closing a form. I have three
> employees (buyers) that we manually assign records for them to work. I would
> like to do this automatically based on the ID# of the record. I have the
> idea of what to do, but not sure how to program it.
>
> In my table - tblreqs - I would like to automatically assign a buyer (# 10
> or #26 or #29) based on the ReqHeaderID.
> On close, if ReqHeader ID ends in 1,4,7, or 0, Buyer = 26; If ReqHeaderID
> ends in 2,5,8 Buyer = 29; If ReqHeaderID ends in 3, 6, 9 Buyer - 10.
>
> Can someone tell me how to write this code? Thanks!

 
Reply With Quote
 
Lori LeRoy
Guest
Posts: n/a
 
      24th May 2010
Thank you both - it works!!!

"PieterLinden via AccessMonster.com" wrote:

> Lori LeRoy wrote:
> >I would like to assign a value to a field when closing a form. I have three
> >employees (buyers) that we manually assign records for them to work. I would
> >like to do this automatically based on the ID# of the record. I have the
> >idea of what to do, but not sure how to program it.
> >
> >In my table - tblreqs - I would like to automatically assign a buyer (# 10
> >or #26 or #29) based on the ReqHeaderID.
> >On close, if ReqHeader ID ends in 1,4,7, or 0, Buyer = 26; If ReqHeaderID
> >ends in 2,5,8 Buyer = 29; If ReqHeaderID ends in 3, 6, 9 Buyer - 10.
> >
> >Can someone tell me how to write this code? Thanks!

>
> dim strRightChar as string
> strRightChar = RIGHT$(ReqHeaderID, 1)
> Select Case strRightChar
> Case 0,1,4,7
> Me.Buyer = 26
> Case 2,5,8
> Me.Buyer = 29
> Case 3,6,9
> Me.Buyer = 10
> End Select
>
> --
> Message posted via AccessMonster.com
> http://www.accessmonster.com/Uwe/For...oding/201005/1
>
> .
>

 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

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

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
How to assign/call a function when a "Close" button of a Form is cliecked? Carla Simeoni Microsoft C# .NET 2 24th May 2007 06:35 PM
Assign Task problem-Can't accept or assign =?Utf-8?B?RE9M?= Microsoft Outlook Calendar 5 29th Jun 2006 06:57 AM
Excel shoud not close all active books when clicking close button =?Utf-8?B?dGVjaG5vbWlrZQ==?= Microsoft Excel Misc 0 10th Jun 2005 05:35 PM
excel - Windows close button (x) should only close active workboo. =?Utf-8?B?Q29mZmVlQWRpY3Q=?= Microsoft Excel Setup 3 8th Feb 2005 04:30 AM
unable to re-assign mail delivery. unable to delete/close duplic. =?Utf-8?B?c2Jyb29rcw==?= Microsoft Outlook Installation 1 28th Dec 2004 12:31 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 12:36 PM.