473,664 Members | 2,728 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Textbox Data Transfer not updating when control is active

6 New Member
I am trying to automatically transfer data from one textbox to another between subforms within a 'main' form. I put this code into the Gotfocus eventprocedure:

Private Sub Date_GotFocus()
If Len(Trim$(Me![Date Fish].Value & "")) = 0 Then
'This checks for blank or space-filled date field - it will only transfer data if it has not already been entered.

Me![Date Fish] = [Forms]![Main Field Data Collection Form]![Field Data Collections Subform].[Form]![Water].[Form]![Date]

SendKeys "{F2}"
SendKeys "{TAB}"
SendKeys "+{TAB}"
End If
End Sub

It works - to an extent. The Sendkeys parts are trying to get the data to show up. It only shows up when I move to another control or subform.

But this is not how I want this to work - and maybe I am not doing this correctly at all.

I enter a date in one subform ("Water" - where data is always collected for that record)

Then I move to another subform ("Fish" where data is only entered for some records). Most often the Date will be the same - but not always. So when I move into the date textbox, I want the date from "Water" to move into the box. Then if it is different, I can edit it, otherwise it is 'defaulted' to the 'Water' date.

Is there a way to do this? I tryed defining the default value, but did not have success - perhaps I did not do it correctly.

The real problem is having the date entered only if data is entered in that subform. If no data is entered, then the date should not be entered either - That means I can not simply populate all the subform dates upon 'Loosing focus' in the 'Water' date subform either.

Hmmmm?
Nov 28 '06 #1
17 2581
MMcCarthy
14,534 Recognized Expert Moderator MVP
You should put this in the Before Update event and your syntax for finding the date on the subform is wrong.

If [Date Fish] is not a Date/Time data type it should be. Then you only have to check for null value.

I would also suggest you change the name of the field in Water subform from Date to something else as Date is a function in Access.

Expand|Select|Wrap|Line Numbers
  1.  
  2. Private Sub Date_BeforeUpdate()
  3.  
  4.    If IsNull(Me.[Date Fish]) Then
  5.       Me.[Date Fish] = [Forms]![Main Field Data Collection Form]![Field Data Collections Subform].Form![Water].Form![Date]
  6.    End If
  7.  
  8. End Sub
  9.  
Nov 28 '06 #2
NeoPa
32,568 Recognized Expert Moderator MVP
Do we want ...Form![Water].Form![Date]?
I would have thought ...Form![Water].[Date]
would be the correct format?
(See I'm learning new stuff all the time - a week ago I wouldn't have had a clue even to ask the question)
Nov 28 '06 #3
MMcCarthy
14,534 Recognized Expert Moderator MVP
Do we want ...Form![Water].Form![Date]?
I would have thought ...Form![Water].[Date]
would be the correct format?
(See I'm learning new stuff all the time - a week ago I wouldn't have had a clue even to ask the question)
We have a subform on a subform with a control. Each subform needs the .Form

Mary
Nov 28 '06 #4
NeoPa
32,568 Recognized Expert Moderator MVP
We have a subform on a subform with a control. Each subform needs the .Form

Mary
In that case would I be right in thinking the .[Water]. part refers to the second level subform object?
In which case we want :
[Forms]![Main Field Data Collection Form].[Field Data Collections Subform].Form.[Water].Form.[Date]
but (!)s can be used in most cases to replace the (.)s if unsure.
Nov 28 '06 #5
NeoPa
32,568 Recognized Expert Moderator MVP
Before you answer that one Mary.
I reread the original post and it looks like two sibling subforms rather than a grandfather - father - son relationship.
Are you sure it SHOULD be referenced as it has?
Nov 28 '06 #6
MMcCarthy
14,534 Recognized Expert Moderator MVP
Before you answer that one Mary.
I reread the original post and it looks like two sibling subforms rather than a grandfather - father - son relationship.
Are you sure it SHOULD be referenced as it has?

I based the code on the original code which indicated that there was a subform Water with a control called [Date] which was on a subform called 'Field Data Collections Subform' which was on a main form called 'Main Field Data Collection Form'.

If this is not the case then the code is wrong.

Just have to wait to find out.

Mary
Nov 29 '06 #7
MMcCarthy
14,534 Recognized Expert Moderator MVP
I based the code on the original code which indicated that there was a subform Water with a control called [Date] which was on a subform called 'Field Data Collections Subform' which was on a main form called 'Main Field Data Collection Form'.

If this is not the case then the code is wrong.

Just have to wait to find out.

Mary
BTW, in this case it doesn't matter that Fish is a subform as long as the reference is on that form.
Nov 29 '06 #8
lokidog
6 New Member
First Thanks much for everything. I changed the Textbox names from date to 'water date' and 'fish date'.

Mary - the code you offered does not work in the Beforeupdate eventproceure area. Nothing happens when put in the Beforeupdate eventprocedure.

The null check is not the problem, This is better than the one I had (I got is from another post here - and seemed sort of unnessesary as date formats won't allow spaces!)

But the Before update event is not registering. Don't know why. Must be a Form Flow Problem.

Maybe this explanation of the forms will help?....

Yes, it's a rather complicated form - but once working it is actually easy to use. The Water form and the Fish Form are 'Sister' forms - on the 'Field Data Collections' Form, which itself is a child form of the 'Main Field Data Collections Form). It allows a data collection of fish and water quality data for a site (field data collection) for numberous years (Main Field Data Collection).

But the dates for each are actually part of the Table that is 'Mother' of both Water and Fish, that is they are on the Field Data Collections Table - there is a 'Water Date' and a 'Fish Date' field on that table. They are entered on the subforms since that is where one enters the water and fish data. The Parent form is for other physical data - so you don't have to jump around a lot on the form.

Maybe this will help?
Nov 29 '06 #9
NeoPa
32,568 Recognized Expert Moderator MVP
No prizes for guessing your gender then ;).
I should just point out that I was not being sexist when I referred to the term 'grandfather - father - son', it's a common term that's been in use to describe this situation for a long time. Your terms are, of course, quite acceptable and intelligible too :).
Nov 29 '06 #10

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

Similar topics

2
2334
by: Edward Mitchell | last post by:
I have Web Form (.aspx file) with a fair number of textboxes (<asp:textbox .... />) that I need to fill from a database and then save back to the database when I'm done. This presumably must be a fairly common problem. If I use brute force, I finish up with a lot of assignments in the Page_Load(...) routine and the same number backwards in the OnClick handler for the submit. In C++ I would create an single array of pointers to the text...
1
4311
by: sekisho | last post by:
I'm dynamically adding a column of labels and a column of text boxes to a panel on a webform, based on data returned from an SQL query, which the user builds by selecting options from a few dropdowns and hitting the 'Search' button. The first column returned is a user name and is added to the panel as a label, the second is a number and is added to the label as the text property of a textbox, so the user can update it. When the...
2
3619
by: Andrew Robinson | last post by:
Is there any way to accomplish two way data binding in a Details View with a DataSet or DataTable as the DataSource. All I want is to get an updated DataSet or DataTable back from the DetailsView and then handle my updating manually. -Andrew
1
2894
by: Zyrthofar | last post by:
Hi I have three textboxes indicating the individual RGB values of a color. When the user leaves a textbox (Leave event), I check the validity of that number and saves the three values to a set of raw data... The sub used handles the three textboxes's Leave events, and uses the 'sender' variable... Now I have a picturebox with GDI+ circles in it, representing the 8 different colors in the palette. You can choose the color number by...
22
3113
by: Tim | last post by:
Hi A while ago I got some help in writing a mock console. The idea was to write a VB app that contained a textbox, then run a process from within the app and redirect the stdout to the textbox. My problem was that textboxes have maximum length limits, so I had to write a function to erase some of the text when it started getting full. That appears to work, but I am experiencing odd behaviour when the textbox text gets long. When it got to...
6
13919
by: JohnR | last post by:
I have a table with 1 row which is used to hold some application wide items (one item per field, hence I only need 1 row). I want to bind one of the fields to a textbox. After setting up the oledbconnection and dataAdapter and filling the DataSet (ds) I tried this: TextBox1.DataBindings.Add("text", ds.Tables.Item("MyFile"), "MyField") I then put the following code in the SAVE button click event:
0
1913
by: CCLeasing | last post by:
Hello, I have searched google but can not find a straight forward answer to my problem. Hopefuly someone will be kind enough to offer their expertise. Please forgive if this seems a bit convoluted but this is probabally a reflection of my not clear understanding of the mechanics behind what i'm trying to achieve. Please bear with it I really could do with your help. I have a simple windows form. There are two controls on the form that I...
9
11940
by: Phill W. | last post by:
VB.Net 2005 SP1 Windows Forms Application What's the fastest way to append text to a TextBox? I have an application that monitors data written to text files. It needs to scan some fairly hefty files (typically ~15MB) and scanning the file pulling out the rows I want (typically ~10,000 of them) takes /comfortably/ under three seconds. In normal usage, this application will "follow" the end of these files as they are written to, so it...
0
2490
by: Mike | last post by:
So here's the situation (.NET 2.0 btw): I have a form, and on this form is a textbox among many other databound controls. The textbox is bound to a field in a data table via the Text property. In this table there are multiple columns that cannot be NULL, which, are bound to other controls (but they're not really important at this time). I create a new row via the currency manager like so: _currencyManager.AddNew() _currentRow =...
0
8437
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
8348
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
1
8549
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
8636
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
1
6187
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5660
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
1
2764
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
2003
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
2
1759
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.