473,394 Members | 1,642 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,394 software developers and data experts.

Auto fill a field in unbound sub-form datasheet

Hi, Programmers I'm Creating a database app for where I work to track plant wear and hopefully use the data to predict plant breakdowns before they happen.
I have a form that contains a sub form & datasheet that is created from SQL query, which is in turn created by selections in three combo boxes on the master form. Which I have got to work exactly as planned.
The Problem is only when I wish to add a new record to the datasheet, there is a foreign key field at the start of the new record I want to auto fill with the "ID" value that is available in a combo box on the master form.

Question: How do I progammatically set the value of that "id"field with the numeric value from the combo box.
Sorry I'm new here so hope this is clear for you.
Thanks
Aug 23 '16 #1
2 2054
Ok I solved this myself,well close enough.
I made a Variable, moved to the acPrevious record in datasheet
set my variable = required field in that record
then moved to acNext record and set that field = my variable.This works ok as long as there actually is at least one previous record for that item.
Aug 24 '16 #2
jforbes
1,107 Expert 1GB
I'm not 100% of what you were/are doing, but this should be some helpful information for you:Refer to Form and Subform properties and controls

So if your situation was one where you wanted to Default a value on the Subform to a value on the MainForm, you could set the Subform Field's Default property to something like:
Expand|Select|Wrap|Line Numbers
  1. =[Me].[Parent].[RecordSource].[SomeID]
and then the value of SomeID from the Parent Form will be put on the all the new records. There are more elegant ways of doing this, but this demonstrates the basic idea.
Aug 24 '16 #3

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

Similar topics

2
by: Galina | last post by:
Hello I have an application in MS Access 2000. I have a form, which includes a subform. The subform is based on a table, but locked for any editing. There is Edit button. When clicked, it starts a...
3
by: MatGyver | last post by:
I am going nuts trying to figure this out, any help will be appreciated. I have an existing table called "Parts". And in this table I have the following columns: "ID" "Part Number" "Part...
2
by: Elainie | last post by:
I have been trying to auto fill fields with DLookup - but it doesn't seem to work..... can you help... I have a name field and I want the address to automatically fill in when the name field...
9
by: DAHMB | last post by:
I have a Report in which I have one of the fields set up to launch a form with the On Click event. I would like to have the form launch and auto fill a field with the value of the field clicked in...
5
by: special1 | last post by:
I would like to be able to auto fill field B with contents of Field a when Field A is a specific word, e.g DNA in Field A would apply to Fields B, C, D etc. Any ideas?
5
by: David Wright | last post by:
Hello Everyone I would be grateful if someone could help me with the automatic increment of a field on my subform called ‘Test_SrNo’. I am Using Microsoft Office 2000. The auto entry of the...
2
by: keirnus | last post by:
Hello, I got something interesting which I hope it really exist. If the title isn't understandable enough, I will explain further. I have a SubForm in Datasheet view. I set SubForm's...
0
by: clarkp73 | last post by:
Hi In VBA I populate an unbound subform (datasheet view) via a recordset that can be changed using filters selected by the user. The only problem I am having is that due to the unbound nature of...
2
by: tamchar | last post by:
I have a form with subform. When the main form is generated the number series of document on field (Called RegNum), and I wont that number series is auto updated to field (called RegNumD) on subform....
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: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
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: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
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...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...

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.