I have a button on mainform that create current time.In the subform, i already have data in some of the fields.
I would like to highlight these specific rows in the subform (select them with mouse) and then add the value created by button on mainform to these selected rows in the subform at once.
Mainform = racef
Subform = timesf
field in subform = timestart
i currently use this code to add the value created by button on mainform, selectively to 1 row in subform at a time. - GetLocalTime MyTime
-
[Forms]![RaceF]![TimeSF]![TimeStart] = Format$(MyTime.wDay, "00") & "/" & Format$(MyTime.wMonth, "00") & "/" & MyTime.wYear & _
-
" " & Format$(MyTime.wHour, "00") & ":" & Format$(MyTime.wMinute, "00") & ":" & _
-
Format$(MyTime.wSecond, "00") & "." & Format$(MyTime.wMilliseconds, "000")
see attachment; value created in button must be added ie to racenumbers 1 and 3 and 5 at once if i select them using mouse. pls assist
5 1846 ADezii 8,834
Recognized Expert Expert
I found no easy way to do this, but I could be wrong in this matter. I did, however, arrive at a solution which you may/may not like, but here it goes along with a Demo Attached. - Create a Field named [Select] Yes/No in the TimeT Table. This Field will serve no real purpose other than to indicate which records will receive the Start Time Value generated from the Main Form.
- Make sure this Field ([Select]) is included in the Sub-Form, TimeSF.
- Select records in the Sub-Form for which you wish to transfer the Start Time.
- Click on the Start Button.
- Clear all the Check Boxes.
- If you like this approach, repeat the process for the Finish Time.
- I'll post the Code below, but see the Attached for a more detailed view.
P.S. - Only relevant Code has been posted. - Private Sub start_Click()
-
Dim MyDB As DAO.Database
-
Dim rst As DAO.Recordset
-
Dim strTimeValue As String
-
-
GetLocalTime MyTime
-
-
Set MyDB = CurrentDb
-
Set rst = MyDB.OpenRecordset("SELECT * FROM [TimeT] WHERE [Select] = True;", dbOpenSnapshot)
-
-
strTimeValue = Format$(MyTime.wDay, "00") & "/" & Format$(MyTime.wMonth, "00") & "/" & MyTime.wYear & _
-
" " & Format$(MyTime.wHour, "00") & ":" & Format$(MyTime.wMinute, "00") & ":" & _
-
Format$(MyTime.wSecond, "00") & "." & Format$(MyTime.wMilliseconds, "000")
-
-
If rst.BOF Or rst.EOF Then
-
MsgBox "No Records Selected", vbCritical, "No Selections"
-
Exit Sub
-
End If
-
-
With rst
-
Do While Not .EOF
-
CurrentDb.Execute "UPDATE [TimeT] Set [TimeStart] = '" & strTimeValue & _
-
"' WHERE [Select] = True", dbFailOnError
-
.MoveNext
-
Loop
-
End With
-
-
CurrentDb.Execute "UPDATE [TimeT] SET [Select] = False;", dbFailOnError
-
-
rst.Close
-
Set rst = Nothing
-
End Sub
ADezii 8,834
Recognized Expert Expert @neelsfer - Oops, think I made a Logic boo-boo. You may wish to revise the previously posted Code to: - Private Sub start_Click()
-
Dim MyDB As DAO.Database
-
Dim rst As DAO.Recordset
-
Dim strTimeValue As String
-
-
GetLocalTime MyTime
-
-
Set MyDB = CurrentDb
-
Set rst = MyDB.OpenRecordset("SELECT * FROM [TimeT] WHERE [Select] = True;", dbOpenDynaset)
-
-
strTimeValue = Format$(MyTime.wDay, "00") & "/" & Format$(MyTime.wMonth, "00") & "/" & MyTime.wYear & _
-
" " & Format$(MyTime.wHour, "00") & ":" & Format$(MyTime.wMinute, "00") & ":" & _
-
Format$(MyTime.wSecond, "00") & "." & Format$(MyTime.wMilliseconds, "000")
-
-
If rst.BOF Or rst.EOF Then
-
MsgBox "No Records Selected", vbCritical, "No Selections"
-
Exit Sub
-
End If
-
-
With rst
-
Do While Not .EOF
-
.Edit
-
![TimeStart] = strTimeValue
-
.Update
-
.MoveNext
-
Loop
-
End With
-
-
CurrentDb.Execute "UPDATE [TimeT] SET [Select] = False;", dbFailOnError
-
-
rst.Close
-
Set rst = Nothing
-
End Sub
Thank you i will try to get it to work tonight
Great idea. Thx Mr Adezi. Sure it wil work
ADezii 8,834
Recognized Expert Expert
Glad it all worked out for you, neelsfer.
Sign in to post your reply or Sign up for a free account.
Similar topics |
by: SHPsalm139 |
last post by:
We have an Access 2K application that uses multiple forms. We
currently hardcode the release number in a label on each form but this
gets tedious to do each time there's a new release. I thought it would
be easy to put the new release number in one spot (a table) and have
each form reference that table/release number in a text box that I
would add to each form but, apparently, it's not as simple as I
expected it to be. Would appreciate...
|
by: Steve |
last post by:
I have a datagrid, which I can highlight multiple rows in. How can I find
out, programmitcally which rows are highlighted?
If I step into the code, and do a Quick Watch on the browser I found this:
((System.Windows.Forms.DataGridRow)(((System.Windows.Forms.DataGrid)(dgWork)).DataGridRows)).selected
property, which is true for the rows selected, but I cant get to this from
within my code???
|
by: Tim Kelley |
last post by:
I have a dataViewgrid in my project in which the user will select multiple
rows. The will click a button and my program will perform some operation on
the selected records (using the ID column value for each of the selected
rows). My question is, how do I loop through the selected rows and
reference the ID column in the data grid? I can get the count of selected
columns, but I don't know how to reference the data in the rows.
Thanks.
|
by: Mike |
last post by:
Class A
public objX
I want to create 2 or more instances of Class A and have the same value for
objX in all instances.
Instance1 of Class A
Instance2 of Class A
Instance3 of Class A
|
by: vlsidesign |
last post by:
This syntax does not to work
nl, nt, ns = 0;
The only one that get's initialized is ns.
nl and nt because they don't initialize seem to get some junk from
memory.
I have done these two versions that work:
nl = 0; nt = 0; ns = 0;
nl = nt = ns = 0;
| |
by: Brett Wesoloski |
last post by:
I am having a bit of a problem getting the current value of the checkbox
list.
I have tried using the selected value as I thought that would give me the
current value of the check box but it appears to be giving me the first
value that is selected all the time.
I have also tried to use the selectedItem property but that does the same as
I would expect becuase the property says it get the item with the lowest
value.
|
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...
|
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed.
This is as boiled down as I can make it.
Here is my compilation command:
g++-12 -std=c++20 -Wnarrowing bit_field.cpp
Here is the code in...
|
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth.
The Art of Business Website Design
Your website is...
|
by: agi2029 |
last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own....
Now, this would greatly impact the work of software developers. The idea...
|
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...
| |
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();...
|
by: TSSRALBI |
last post by:
Hello
I'm a network technician in training and I need your help.
I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs.
The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols.
I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
|
by: adsilva |
last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
|
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...
| | |