Transfer from One Form to Another Form

nylex

New member
Local time
Tomorrow, 01:54
Joined
Sep 17, 2011
Messages
6
I have a Main Form "SalesOrders" and a Subform "SalesOrdersSubform" - the subform is linked to the main form by "SalesID" no.
I have a third form "PrevPurchases" which list the products that the customer has purchased in the past and is filtered from the Main form by the "ClientName"
In the Past Purchases form i have it that if they DoubleClick the name of a product hat they have purchased in the past then it Makes an entry in the "SalesOrderSubform" and then I try to move the cursor tyo it but cant. It makes the entry, I then change focus and then the New Entry product name is hilited but the Cursor is stays on the product name that was doubleclicked - I cant seem to get the cursor to go to the place that has the set focus
Code is as follows
>>>>>>>>
Private Sub description_DblClick(Cancel As Integer)
Dim StockCode As String
Dim OrdNo As Integer
OrdNo = [Forms]![SalesOrders]!SalesID
StockCode = stock_id
Call OrderAdd(StockCode, OrdNo)
[Forms]![SalesOrders]![SalesOrdersSubform].SetFocus
DoCmd.Requery
DoCmd.GoToRecord , , acLast
Forms!SalesOrders!SalesOrdersSubform.Form!Product.SetFocus
End Sub
>>>>>>>>>>
The only way to move the cursor is to place the mouse over the new product and click - Problem is some staff just press the "Enter" key and that takes them to the next record in the PrevPurchases list
 
nylex,
Bear in mind that I have not tested this, but here is my suggestion. Get the setfocus out of the double click event. Perhaps create a procedure with the setfocus and after all else has executed in the DC event, the last line calls the procedure with the setfocus stuff. If that doesn't work, there is always the exit or lost focus event of the description field so when the staff hit enter and move away, the code moves them to the other form. Last resort, remove the double click and put a command button on the form, that will probably work, but they loose functionality. Plus all the retraining.

Let me know if it works.
Privateer
 
I have a third form "PrevPurchases" which list the products that the customer has purchased in the past and is filtered from the Main form by the "ClientName"
You didn't mention where this subform is placed? And why is it filtered via ClientName and not ClientID? Is it actually filtered or linked?

In the Past Purchases form i have it that if they DoubleClick the name of a product hat they have purchased in the past then it Makes an entry in the "SalesOrderSubform" and then I try to move the cursor tyo it but cant.
Code is as follows
>>>>>>>>
Private Sub description_DblClick(Cancel As Integer)
Dim StockCode As String
Dim OrdNo As Integer
OrdNo = [Forms]![SalesOrders]!SalesID
StockCode = stock_id
Call OrderAdd(StockCode, OrdNo)
[Forms]![SalesOrders]![SalesOrdersSubform].SetFocus
DoCmd.Requery
DoCmd.GoToRecord , , acLast
Forms!SalesOrders!SalesOrdersSubform.Form!Product.SetFocus
End Sub
>>>>>>>>>>
Look at those highlighted lines, doesn't that counteract what you're trying to do?

Also, from that code line, can I conclude that Product is the name of the subform control that houses the PrevPurchases form? Which means that PrevPurchases is actually a subform in SalesOrdersSubform.
 
I have set the on focus to the the event and it works fine

Doesnt Work - evertime I create new order the subform loads - gets focus and immediately makes an entry of the last product on the list

It does goto the right spot in the details subform tho
 
Last edited:
thanks for this everyone; for helping Nyles as it has now helped me..

I have had an almost similar problem with transferring focus from an invoice to another screen via a double click.. I also had a command button that worked perfectly but the double click would not (being human most of us like to double click, so I need to have that feature in the application)..

The focus would always return to the last screen even after opening the new screen when the double click was carried out..

After pulling my hair out for a day trying many different approaches looking for an error, trying to trap the error, and seeing what else could possibly be causing it I came over here for a read.. And in the end the solution was so obvious I dont know why I didnt see it myself, sometimes we are just too close to the problem.

I resolved it by switching the focus to the command button that worked, so the moment the double click action had been carried out I had the focus shit to the command button, then I used the call to run the underlying code in the command button. Because the focus had shifted away from the text box it never returned once the code had finished running.....

awesome... thanks


I do love coming here for solutions...
 

Users who are viewing this thread

Back
Top Bottom