Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
Discussion GroupsFormsForms ProgrammingQueriesModules / DAO / VBAReports / PrintingMacrosDatabase DesignSecurityConversionImporting / LinkingSQL Server / ADPMultiuser / NetworkingReplicationSetup / ConfigurationDeveloper ToolkitsActiveX ControlsNew UsersGeneral 1General 2
Access DirectoryToolsTutorialsUser Groups
Related Topics
SQL ServerOther DB ProductsMS OfficeMore Topics ...

MS Access Forum / General 1 / March 2006

Tip: Looking for answers? Try searching our database.

Updating a Field Value From a Dialog

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
charles.elias@wpafb.af.mil - 31 Mar 2006 16:56 GMT
I am very new to Access.  I have created a database in Access 2003.  I
can enter the required record fields from a form.  I would like to add
a feature that allows a user to update the "quantity" field (it is type
long integer).  The update would be to add or subtract a user-entered
number to/from the current quantity.  Perhaps a dialog would pop up on
entry to the quantity field.  The user would enter a number and press
"Add" or "Subtract" to perform the desired action.  Unfortunately, I
don't yet know how to make this happen.

As it is now, the user can change the quantity field but would have to
calculate the new value if he/she wanted to add or subtract to/from the
current quantity.

Thanks for any quidance you can give me on this.

Charles
Susan K - 31 Mar 2006 19:27 GMT
Charles,

I would suggest that you could add code to the On Enter of the Quantity
field that would ask the user for the change in the quantity. But, if
you do that, I would lock the quantity so it could not be changed in
any other way.

So, to lock the quantity field, bring up the properties and on the Data
tab, click Locked and check Yes.

Then give the Quantity field a name - like lngQuantity - the name is
found on the Other tab of the Properties.

On the Events tab, find On Enter and click in the white field. Click on
the three dots and select Code Editor.

Add between the Private Sub and End Sub on blank lines:

On Error Resume Next

Dim lngQty As Long
dim strAnswer as String

'As a note, the following should all be one line
strAnswer = InputBox("What do you want to increment the quantity by? If
you want to lower the quantity, put a minus in front of the number.)"

lngQty = val(strAnswer)

if lngQty <> 0 then

    'The next line is also one line
    me.cboQuantity.value = me.cboQuantity.value + lngQty

End If

_____________________END OF CODE

This tells the computer if there is a problem just keep going.

Sets up two variables to hold the answer given and convert it to a
number.

Then, if the number is anything other than zero it is added to the
existing number.

Be sure to notice where I have left you notes for lines that should not
wrap.
charles.elias@wpafb.af.mil - 01 Apr 2006 00:57 GMT
> Charles,
>
[quoted text clipped - 44 lines]
> Be sure to notice where I have left you notes for lines that should not
> wrap.

Susan,

Thanks so much for your help.  I'll give your suggestion a try.

Charles
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.