473,385 Members | 1,813 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,385 software developers and data experts.

Automatic Data Entry into Form Fields - How?

I'm using Access 2003, on Windows XP Pro.

I have a subform which is launched from a command button on my main form. When this form opens, I have 2 fields which I have inserted VBA Code into to capture the information in two of the fields on the main form, so I can sync and track the data entered into the subform to the record on the mainform.

In the "Got Focus" event of each of the two fields I've inserted the following code, to capture the data from the main form:

Expand|Select|Wrap|Line Numbers
  1.  Me.ActiveControl = Forms!F_KSM_Contacts_Sc!SM_Contacts_ID 
and

Expand|Select|Wrap|Line Numbers
  1.  Me.ActiveControl = Forms!F_KSM_Contacts_Sc![SM_S-PersonRef] 
This works great to capture the data, however it requires me to have the user tab through these two fields in order to have the data be pulled into the fields in question. I want to automate this so that these fields capture that data automatically upon the form opening, but I don't know how to write the syntax in such a way as to make this happen.

I have tried using SendKeys to try and send a "Tab" command using:

Expand|Select|Wrap|Line Numbers
  1.  SendKeys vbKeyTab, 0  
in several properties, including the "On Open" property of the form (thinking that on open it would send two tab keys, which, if the two fields were the first two in the tab order it would tab through them, and thus the data would be pulled in. However this does not work.

Any suggestions for the easiest way to do this? I'm a beginner at VBA and I have a bit of trouble translating the syntax definition into a working syntax statement, so please give me some comments in any suggested code, as a guide. Thanks
Sep 28 '06 #1
1 4833
Tanis
143 100+
Avoid SendKeys at all costs. I think ther may be an easier way.Why not refer to the fields implicitily. Something like this behind your command button. Not too sure about the syntax for subforms though.
Expand|Select|Wrap|Line Numbers
  1.  DoCmd.OpenForm "frmSubFormName", acNormal, "", "[PrimaryKeyField]=[Forms]![frmMainForm]![PrimaryKeyField]", acAdd, acNormal
  2.  
  3. Forms![frmSubForm]![PrimaryKeyField] = Forms!frmMainForm![PrimaryKeyField]
  4.  
  5. Forms![frmSubForm]![YourControlName1] = Forms!frmMainForm![YourControlName1]
  6.  
  7. Forms![frmSubForm]![YourControlName2] = Forms!frmMainForm![YourControlName2] 
Sep 29 '06 #2

Sign in to post your reply or Sign up for a free account.

Similar topics

9
by: Don Seckler | last post by:
I am trying to set up a PHP web page so I can enter data into a database. I created a form: <form action="admin_news_insert_processor.php" method="post" name="frm_Insert_News"...
0
by: Dave | last post by:
Hi, I'm creating a form based on a table. This table has fields including UniqueID (auto numbered and different for each entry), Track (3 different types), ClassYear (4 different years), and...
4
by: m_houllier | last post by:
STUDENT TABLE StudentReference Student Name etc ATTENDANCE TABLE AttendanceID CourseID StudentReference
1
by: Trent | last post by:
I am in the design phase of a new database and am having a devil of a time with a subform. I have three tables that relate to problem - Suppliers tbl, Customers tbl and a SuppliersCustomers tbl....
6
by: Wayne | last post by:
I am designing a database which needs approximately 50 fields per record. The database user requires data entry to be via a single screen. If I follow good database design practice and split the...
2
by: filbennett | last post by:
Hi Everyone, I'm generally unfamiliar with Access form design, but have programmed Cold Fusion applications for a couple of years. I'd like to build a data entry form in Access that allows the...
1
by: NumberCruncher | last post by:
Hi All, I am struggling with setting up my first system of tables, forms,and reports, and could use your help! I am setting up a database to keep track of the production of a produced item. The...
4
by: =?Utf-8?B?Q2FybGluIEFuZGVyc29u?= | last post by:
I have a large classic ASP web application which needs to now support chinese character entry (I don't have to worry about the UI yet - the data entry people can read english). Other than changing...
2
kcdoell
by: kcdoell | last post by:
Hello: I have four tables: tblDivision tblWorking_Region tblCredit_Region tblForecast (This is the main data entry table for all forecasting records) tblDivision has the following fields:
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.