Inserting current from open form to another form. (1 Viewer)

Fira_g

Registered User.
Local time
Today, 10:22
Joined
Oct 17, 2019
Messages
60
Hi. If you don't mind, I do have a couple of questions about it.

  1. What is the difference between Pick and Drop locations?
  2. In tblOrders, does EmployeeID refers to the person who took the order?
  3. Are drivers not considered as "employees?" If they are, how come they're not in the Employees table?
That's it for now...

Pickup and Drop locations are 2 different geographical locations. Driver goes to the Pick location takes the load delivers to the Drop location.

Yes, EmployeeID is the person that who took the order.
Drivers are mainly contractors, but I was thinking of merging this 2 tables.
 

Fira_g

Registered User.
Local time
Today, 10:22
Joined
Oct 17, 2019
Messages
60
In any case, if you are looking for a way to copy the current CustomerID on your form to another, you could try the following syntax:


Forms!NameOfOtherForm.NameOfControlOnThatForm = Me.CustomerID


However, for the above syntax to work, the other form must also be open to accept the value you are transferring.

Any ideas why my the current code doesn't work?:

Code:
Private Sub InserttoMainOrder_Click()
DoCmd.OpenForm "frmMainOrders", , , "CustomerID = " & Me.CustomerID
End Sub
 

theDBguy

I’m here to help
Staff member
Local time
Today, 07:22
Joined
Oct 29, 2018
Messages
21,358
Any ideas why my the current code doesn't work?:

Code:
Private Sub InserttoMainOrder_Click()
DoCmd.OpenForm "frmMainOrders", , , "CustomerID = " & Me.CustomerID
End Sub

Hi. What does "doesn't work" mean? The form is not opening? It's not filtering to the correct customer? Are you getting any errors?
 

Fira_g

Registered User.
Local time
Today, 10:22
Joined
Oct 17, 2019
Messages
60
The frmMainOrders opens but nothing the value won't transfer, just a blank form.
 

theDBguy

I’m here to help
Staff member
Local time
Today, 07:22
Joined
Oct 29, 2018
Messages
21,358
The frmMainOrders opens but nothing the value won't transfer, just a blank form.

Hi. Did you try the syntax I gave you earlier? And how come you don't want to switch to a subform? Just curious...
 

Fira_g

Registered User.
Local time
Today, 10:22
Joined
Oct 17, 2019
Messages
60
The syntax you provided works exactly as you advised: other form needs to be opened and the focus remains on the Customer form.

The Order form(frmMainOrders) works with no problem. I type the customer name in Customer field and it filters it as I type, thanks to help from members of this website.
Now when I want to add new customer that is not in the list, I click the + button and it takes me to the Customer form, so I add new customer.
Now as I am on the Customer form rn, I want a button on that form to populate the newly added CustomerID from the Customer form back to the MainOrders form.
That is why )
 

theDBguy

I’m here to help
Staff member
Local time
Today, 07:22
Joined
Oct 29, 2018
Messages
21,358
The syntax you provided works exactly as you advised: other form needs to be opened and the focus remains on the Customer form.

The Order form(frmMainOrders) works with no problem. I type the customer name in Customer field and it filters it as I type, thanks to help from members of this website.
Now when I want to add new customer that is not in the list, I click the + button and it takes me to the Customer form, so I add new customer.
Now as I am on the Customer form rn, I want a button on that form to populate the newly added CustomerID from the Customer form back to the MainOrders form.
That is why )
So, the syntax should still work the same even if you're on the new customer form. Perhaps, if you could post a sample copy of your db, we could see where the disconnect is. But again, if it was me, I think a form/subform would be a simpler solution for this. Just my 2 cents...
 

Fira_g

Registered User.
Local time
Today, 10:22
Joined
Oct 17, 2019
Messages
60
I need to keep the form as it is rn as that is how it was requested, because it should be about the order/load not about customer. I will have a query/Form that will show orders by customer that will be Customer form with orders subform in datasheetview.

I am using code below now to open the main form, transfer the value and and close the customer form

Code:
If IsNull(Me.CustomerID) Then
    MsgBox "Please Select or Add a Company First", vbOKOnly
    Me.CustomerID.SetFocus
    Exit Sub
End If

DoCmd.OpenForm "frmMainOrders"
Forms!frmMainOrders.CustomerID = Me.CustomerID
DoCmd.Close acForm, "frmCustomers"

It seems to work, but I am pretty sure it needs some improvements.
 

theDBguy

I’m here to help
Staff member
Local time
Today, 07:22
Joined
Oct 29, 2018
Messages
21,358
Hi. Glad to hear you got it sorted out. Good luck with your project. We'll be here if you need us again.
 

Users who are viewing this thread

Top Bottom