Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

using the value of a text box on 1 form to change the value of another 1

Status
Not open for further replies.
Feb 19, 2005
47
0
0
GB
Hi there. I have several forms on my database, but the problem concerns frmDelivery and frmItem. On the Delivery form, there is a sub form called subDeliveryDetails. On this form there is a text box (txtQuantityReceived), which contains the quantity of a particular item which has been recieved. On the item form, there is a text box (txtItemQuantityInStock) and this contins the item quantity in stock. I want the quantity in stock to update once a delivery is recieved. If I can do this without a button, please let me know. At the minute, I have tried to create a button called 'update'. The code I have entered on the buttons' on click is as followed:

Private Sub cmdUpdate_Click()
On Error GoTo Err_cmdUpdate_Click

Dim stDocName As String
Dim stLinkCriteria As String

IntNum = QuantityRecieved.Value

stDocName "frmItem"

stLinkCriteria = "[ItemCode]=" & "'" & Me.subDeliveryDetails![ItemCode] & "'"
DoCmd.OpenForm stDocName, , , stLinkCriteria

Forms.frmItem![ItemQuantityInStock].Value = Forms.frmItem![ItemQuantityInStock].Value + IntNum

DoCmd.Close

Exit_cmdUpdate_Click:
Exit Sub

However, this doesn't work, and when i try to un it I get a message box which says error expected sub or function or property, and the line "stDocName "frmItem"" is highlighted.

Can anyone explain what is wrong with this code, or suggest an alternative? Thanks!
 
Replace this:
stDocName "frmItem"
By this:
stDocName = "frmItem"

Anyway, take a look at the Northwind database...

Hope This Helps, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884 or FAQ222-2244
 
Get your procedure working with the button first. Then, to run it without the button....

Set the button's visible property to NO.
In the AfterUpdate event of the field you enter deliveries in, place this code....
Private Sub TextBoxName_AfterUpdate
ButtonName_Click
End Sub


This will cause the button's click event to run without actually clicking the button.


Randy
 
PHV, I have tried that, and it says object required. I think maybe because the data I want to grab is in a subform?
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top