Wrox Programmer Forums
|
Access VBA Discuss using VBA for Access programming.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Access VBA section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old February 5th, 2007, 02:01 PM
Friend of Wrox
 
Join Date: Apr 2006
Posts: 159
Thanks: 0
Thanked 0 Times in 0 Posts
Default 1 form for multiple inputs

Hi,

I have a form named "frmInlogBAM" that is used as a menu. On this form I'm working with different sheets (or tab control if I remember). On Every sheet I have an action button that takes the user to the same form named "frmArtikel". The command buttons names are for exemple "cmdArtikelBA01", "cmdArtikelBA02", cmdArtikelBA05",... They are coming form the sheets "TabBA01", "TabBA02", "TabBA05",...

On the form "frmArtikel" that is used to input data in the table I have 3 fields: "ArtikelNumber", "ArtikelName" and "ArtikelDepartment".

Now what I would like to have is that when I use the cmdArtikelBA02 command button to go to the form, the ArtikelDepartment field of the "frmArtikel" form gets the default value BA02. If it's coming from the "cmdArtikelBA05" button it has to be BA05... The ArtikelDepartment field is locked, so the user can't change the value.

What I tried was putting

dim artOriginator as commandbutton

in a module, and then try to get this into the form "frmArtikel". On the action button that takes me to the form I use

set artOriginator = BA02 (also tried "BA02")

but when I do this I get an error.
I also use
set artOriginator = Nothing on the command button that takes me back from the "frmArtikel" form to the "frmInlogBAM" menu.

Does anyone know what I should change about the set artOriginator on the command button and what I should add on the "frmArtikel" on current event to make this work? (I guess I'll have to use the on current event...)

 
Old February 5th, 2007, 05:07 PM
Friend of Wrox
 
Join Date: Mar 2004
Posts: 3,069
Thanks: 0
Thanked 10 Times in 10 Posts
Default

I wouldn't use the On Current event.

You can either pass the value in a public variable, and use On Load event to set the field value to the value in the public variable. Set the public variable on the On Click event of the button opening the form.

So in a module, do this:

Public sDept As String

Then on the On Click event of each button, send the Department, like this:

cmdArtikelBA02 On Click event:
sDept = "BA02" 'use quotes since it is a string.

Then on the On Load event of the form, do this:

Me.ArtikelDepartment = sDept

If you are going to allow the user to continue to create records in the same table after the first record is entered after loading the form, then use the record number, subtract one, and use the last department value.

Did that work?


mmcdonal
 
Old February 6th, 2007, 04:06 AM
Friend of Wrox
 
Join Date: Apr 2006
Posts: 159
Thanks: 0
Thanked 0 Times in 0 Posts
Default

When I open the form, no value is entered in the ArtikelDepartment field. If I change me.artikeldepartment = sDept to me.artikeldepartment.defaultvalue = sDept I get #Name in the artikeldepartment field...

I don't know if this is important, but data locked = yes

About the next record with the action button with the record number: I'm not using a record number in this table. I only have those 3 fields and the primary key is a combination of artikelnumber and artikeldepartment.






Similar Threads
Thread Thread Starter Forum Replies Last Post
How to accept inputs from user for encryption? m.ganguli BOOK: Beginning Cryptography with Java 1 March 5th, 2007 03:53 AM
FLASH User Inputs IP076 Flash (all versions) 1 January 5th, 2007 12:23 AM
Passing Query Inputs To Reports socoolbrewster Access 4 February 25th, 2005 12:59 PM
Multiple Form Instances in a single form? gman997 ASP.NET 1.0 and 1.1 Basics 1 March 30th, 2004 06:46 PM
Multiple inputs on same page kev_79 Access 3 July 8th, 2003 11:16 PM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.