Access: Load data from one form to another

gheyman

Well-known Member
Joined
Nov 14, 2005
Messages
1,730
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

Bring active cell back into view
Start at A1 and select to A9999 while writing a formula, you can't see A1 anymore. Press Ctrl+Backspace to bring active cell into view.

Joe4

MrExcel MVP, Junior Admin
Joined
Aug 1, 2002
Messages
53,631
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,730
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,631
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
820
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,101,941
Messages
5,483,817
Members
407,415
Latest member
Anton1999

This Week's Hot Topics

  • Finding issue in If elseif else with For each Loop
    Finding issue in If elseif else with For each Loop I have tried this below code but i'm getting in Y column filled with W005. Colud you please...
  • MsgBox Error
    Hi Guys, I have the below error show up when i try and run my macro in File1 but works fine if i copy and paste the same code into file2. [ATTACH...
  • CELL FORMAT - IF CONDITION
    My Cell Format is [B]""0.00" Cr". [/B]But in the cell, it is showing 123.00 for editing. (123 is entry figure). (Data imported from other...
  • Show numbers nearly the same
    Is this possible. I have a number that can change very time eg 0.00001234 Then I have a lot of numbers 0.0000001, 0.0000002, 0.00000004...
  • Please i need your help to create formula
    I need a formula in cell B8 to do this >>if b1=1 then multiply ( cell b8) by 10% ,if b1=2 multiply by 20%,if=3 multiply by 30%. Thank you in...
  • Got error while adding column and filter
    Got error while adding column and filter In column Z has some like "Success" and "Error". I want to add column in AA if the Z cell value is...
Top