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

setting default values

116 100+
I am working on setting a default time when a form is opened.

Expand|Select|Wrap|Line Numbers
  1. DoCmd.GoToRecord acActiveDataObject, , acLast
  2.  
  3. Start_Time.DefaultValue = """" & DateAdd("n", 0, Me.PlannedfinishTimesplit) & """"
  4.  
  5.  
This is working as it should but i have set a bound text box to select a different machine to get a different list. When a different list is selected it still picks up the default time from the previous sheet. I thought it would work if i set the code on the afterupdate for the machine but it kicks up errors. Could anyone help. I have attached the database to explain.

Thanks
jacc14
Attached Files
File Type: zip problem.db1.zip (171.4 KB, 215 views)
Jul 7 '10 #1

✓ answered by Jerry Maiapu

Try on the On_Current event. I am just wondering if Start_Time is a control on the form. Because I do not see any control with that name in the forms. I think there is a Start Time control on the sub form.

If the the control is in the sub-form try in the On_Current event of the sub-form.

9 1772
Jerry Maiapu
259 100+
Try on the On_Current event. I am just wondering if Start_Time is a control on the form. Because I do not see any control with that name in the forms. I think there is a Start Time control on the sub form.

If the the control is in the sub-form try in the On_Current event of the sub-form.
Jul 7 '10 #2
nico5038
3,080 Expert 2GB
Dear jacc14,

Using a query based on three tables for a subform is asking for trouble as it might turn the subform into a "non-update" state. Best to use "plain" tables as rowsource.

The default value for a starttime is best set in the corresponding table, thus Access will put it there when a row is added, regardless or you're appending a row in the table directly or using a form.

Nic;o)
Jul 8 '10 #3
jacc14
116 100+
@Jerry Maiapu
Hi Jerry. You are right the Start_time is a control on the form. I have tried your suggestion with OnCurrent and success.
Thank you so much

Jacc14
Jul 8 '10 #4
jacc14
116 100+
@jacc14
Hello Jerry. I think i spoke too soon. I have put the following code on current :-
Expand|Select|Wrap|Line Numbers
  1. Start_Time.DefaultValue = """" & DateAdd("n", 0, Me.PlannedfinishTimesplit) & """"  
This works but the moment I start to enter a new line it just blanks out the defaultvalue as its looking at the current line. I basically want to set it and it then not change again if I move around the form.

Any ideas please
Thanks
Jacc14


ps on a different approach I have tried the following

Expand|Select|Wrap|Line Numbers
  1.  Private Sub machine_AfterUpdate()
  2. Me.Requery
  3.  
  4. With Me.[Qry_sections_subform]
  5. .SetFocus
  6. .Form![Job no].SetFocus
  7. End With
  8. DoCmd.GoToRecord acActiveDataObject, , acLast
  9.  
  10.  
  11. Start_Time.DefaultValue = """" & DateAdd("n", 0, Me.PlannedfinishTimesplit) & """"
  12.  
  13.  
  14. End Sub
  15.  
The idea is that when the machine is changed it then goes to the last record in the subform and applies the defaultvalue. However it returns OBJECT NOT SET. I am confused as when I set the default value ON LOAD of the subform it works perfect but as soon as I change the machine it just retains the original value from the first page. Its as if I need to do it on RELOAD.
Jul 8 '10 #5
Jerry Maiapu
259 100+
Ok am busy right now tell me Start_Time is on the sub-form or parent. I'll go through test it and come back later.

Ta..
Jul 9 '10 #6
jacc14
116 100+
Hi Jerry. Yes the Start_time is in the sub form
best regards
Chris
Jul 9 '10 #7
Jerry Maiapu
259 100+
See suggestion
Jul 13 '10 #8
Jerry Maiapu
259 100+
Hi Chris, I am sorry.. I was quite busy and almost forget.

Now, the problem you seem to face I guess is because of the fact that you want to set a default value in[Start Time] based on the value of the last record in one of you columns[PlannedfinishTimesplit].

Well, remember that PlannedfinishTimesplit will have many value list and to pick the desired value will be quite unpredictable.

If you look at the behavior you'll see that whenever you place the cursor in one of the field values of PlannedfinishTimesplit,the current value will change as default on the Start_Time .

I think what you should do is use First/Last function to get the last value for PlannedfinishTimesplit on the subform footer and set this as the default value for Start_Time and fire it on the On_Current event of the child form.

And also remove this portion of the code you placed on onload event of the subform:

Expand|Select|Wrap|Line Numbers
  1. Start_Time.DefaultValue = """" & DateAdd("n", 0, Me.PlannedfinishTimesplit) & """"
and instead put on On_Current event like I posted earlier.

Cheers
Jul 13 '10 #9
jacc14
116 100+
Hi Jerry. thanks for taking the time. I can work with this.

Cheers
Chris
Jul 15 '10 #10

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

Similar topics

11
by: Harlin Seritt | last post by:
There are certain options for Tkinter widgets that have default values that I don't much care for (borderwidth, font come to mind) and continuously change when I'm building interfaces. With a bit...
6
by: My Deja | last post by:
what is the syntax for specifying the default values for timestamps in MySQL in the CREATE TABLE command? I have 2 timestamps, one for when the record was entered, the other for any subsequent...
1
by: Bruce Rusk | last post by:
I've just started using Stephen Lebans' RTF2 control in a database, linked to a Memo field, and am finding it extremely useful (incidentally, in ACC2002 I'm using the class and withevents rather...
5
by: Ed Havelaar | last post by:
I have a cool function that I want to use as a default value for a column in my table. But I can't because apparently Access doesn't allow user defined functions in expressions for default values....
3
by: countd4 | last post by:
I have built a working user control. However, to make it work, I always have to set certian properties using the properties sheet for the control when using it on other forms. I want to be able to...
4
by: John Scott | last post by:
I want to be able to set some default values in my web application ....like..setting all strings to "" and all integers to int.MinValue....etc... I have a web application object that is based on...
1
by: tg.foobar | last post by:
my setup: visual studio 2005 sql server 2000 i'm using a dataset (used to be called typed dataset in 2003), where i use the MSDataSetGenerator to create a class for me based on the scheme of...
1
by: cweibel | last post by:
This should be an easy problem for those with far more knowledge than myself with databinding. I have a VB.NET 2005 windows form with several checkboxes, textboxes and datepickers which are...
1
by: Will | last post by:
I am upsizing an access application to vb.net. In access textbox, combos and checkboxes can have default values, which are assigned in the properties for the control. How can I set a control's...
1
by: leedspaddy | last post by:
Hi there, I set the default value of a combo box on a form using the following code in the properties box: cboContactType.itemdata(0) and of course nothing happens. I just want the combo box to...
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
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
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
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...
0
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...
0
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...
0
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...

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.