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 1826
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
@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
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...
|
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...
|
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...
|
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...
|
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...
|
by: taylorcarr |
last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
|
by: Charles Arthur |
last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
|
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$) {
}
...
|
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...
|
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...
|
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...
|
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...
|
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,...
|
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...
| | |