Access: Load data from one form to another

gheyman

Well-known Member
Joined
Nov 14, 2005
Messages
1,720
I have code that loads data that is selected on one form to another form (Someone here helped me with - thanks!!!!!)

The code runs great except for the last line that I tried to add. I want filed "_Upload" to equal "Y". Its a Combo box Formatted True/False

Code:
Private Sub LoadItemId_Click()
[Forms]![frm_VendorQuoteData].[ITEM_ID].Value = Me.ItemID.Value
[Forms]![frm_VendorQuoteData].[_ITEM_ID_DESC].Value = Me.Description.Value
[Forms]![frm_VendorQuoteData].[ITEM_RVSN_ID].Value = Me.Rev.Value
[Forms]![frm_VendorQuoteData].[_COMMD_CODE].Value = Me.Commodity.Value
[Forms]![frm_VendorQuoteData].[QT_UM_CD].Value = Me.UM.Value
[Forms]![frm_VendorQuoteData].[_Upload] = "Y"
End Sub
Also how do I ensure that form "frm_VendorQuoteData" is open when code is run?. I don't want to open the form, I want to make sure it was already open.

Thanks
 
Last edited:

Some videos you may like

Excel Facts

Can Excel fill bagel flavors?
You can teach Excel a new custom list. Type the list in cells, File, Options, Advanced, Edit Custom Lists, Import, OK

Joe4

MrExcel MVP, Junior Admin
Joined
Aug 1, 2002
Messages
53,045
Office Version
365
Platform
Windows
If it is a True/False field, it stored values are typically True/False, or numerically -1, 0 (and not the string value "Y").

So try:
Code:
[Forms]![frm_VendorQuoteData].[_Upload] = True
or
Code:
[Forms]![frm_VendorQuoteData].[_Upload] = -1
 
Last edited:

gheyman

Well-known Member
Joined
Nov 14, 2005
Messages
1,720
Thanks Joe. Is there a way to make sure the form "frm_VendorQuoteData" is open before the code is run?
 

Joe4

MrExcel MVP, Junior Admin
Joined
Aug 1, 2002
Messages
53,045
Office Version
365
Platform
Windows
How is this code being called? Is it being called from an event on that Form (if so, the Form would have to be open already)?
If not, you will need to add a "DoCmd.OpenForm" command at the beginning of your code.

Note, I see that you have a few question recently that involve using the various "DoCmd" commands.
Most of these are available under the "Macros" sections. A good way to get the exact code that you need with all the right arguments/values is to create a simple Macro to perform that action (i.e. Open a specific form). Then, convert that Macro to VBA code using the "Convert Macros to Visual Basic" action (found on Macro toolbar). Then, you can just copy/paste the needed lines of code that you need from the converted function to your VBA code.
 

welshgasman

Well-known Member
Joined
May 25, 2013
Messages
777
https://social.msdn.microsoft.com/F...test-to-see-if-a-form-is-open?forum=accessdev

Found using https://www.google.com/search?ei=K5.....0.0..0.0.0.......0......gws-wiz.L9NbBf0X6h0

I have code that loads data that is selected on one form to another form (Someone here helped me with - thanks!!!!!)

The code runs great except for the last line that I tried to add. I want filed "_Upload" to equal "Y". Its a Combo box Formatted True/False

Code:
Private Sub LoadItemId_Click()
[Forms]![frm_VendorQuoteData].[ITEM_ID].Value = Me.ItemID.Value
[Forms]![frm_VendorQuoteData].[_ITEM_ID_DESC].Value = Me.Description.Value
[Forms]![frm_VendorQuoteData].[ITEM_RVSN_ID].Value = Me.Rev.Value
[Forms]![frm_VendorQuoteData].[_COMMD_CODE].Value = Me.Commodity.Value
[Forms]![frm_VendorQuoteData].[QT_UM_CD].Value = Me.UM.Value
[Forms]![frm_VendorQuoteData].[_Upload] = "Y"
End Sub
Also how do I ensure that form "frm_VendorQuoteData" is open when code is run?. I don't want to open the form, I want to make sure it was already open.

Thanks
 

Watch MrExcel Video

Forum statistics

Threads
1,095,841
Messages
5,446,822
Members
405,417
Latest member
egrospe17

This Week's Hot Topics

Top