Hi, this is what I'm doing:
1 - create a table [2 fields], let's call it "greetings". Populate it with 5 records:
field1 , field 2
==========================
hi , bye
hola , adios
hein , struchtlicht
bon jour, au revoir
hallo , ha det
2 - create a form with the datasheet default view
3 - Whenever i add a new record (using the form), i want to write a sub that displays a msgbox with the values of field 1. (hi, hola, hein, bon jour, hallo)
I've tried different stuff with recordsets but i all get are errors.
Thanks
- Assuming your Form is based on a Table named tblGreetings with 2 Fields:
- [Field1] {TEXT}
- [Field2] {TETXT}
- Your Form consists of at least 2 Fields whose Control Sources are : [Field1] and [Field2].
- In the AfterUpdate() Event of your Form, place the following Code:
-
Private Sub Form_AfterUpdate()
-
Dim MyDB As DAO.Database
-
Dim rst As DAO.Recordset
-
Dim strBuild As String
-
-
Set MyDB = CurrentDb
-
Set rst = MyDB.OpenRecordset("tblGreetings", dbOpenForwardOnly)
-
-
With rst
-
Do While Not .EOF
-
strBuild = strBuild & ![Field1] & ", "
-
.MoveNext
-
Loop
-
End With
-
-
If strBuild <> "" Then MsgBox Left$(strBuild, Len(strBuild) - 2)
-
-
rst.Close
-
Set rst = Nothing
-
End Sub
-
- OUTPUT (String in Msgbox() after adding a New Record):
- hi, hola, hein, bon jour, hallo, New Field1 Value
3 1331 - Assuming your Form is based on a Table named tblGreetings with 2 Fields:
- [Field1] {TEXT}
- [Field2] {TETXT}
- Your Form consists of at least 2 Fields whose Control Sources are : [Field1] and [Field2].
- In the AfterUpdate() Event of your Form, place the following Code:
-
Private Sub Form_AfterUpdate()
-
Dim MyDB As DAO.Database
-
Dim rst As DAO.Recordset
-
Dim strBuild As String
-
-
Set MyDB = CurrentDb
-
Set rst = MyDB.OpenRecordset("tblGreetings", dbOpenForwardOnly)
-
-
With rst
-
Do While Not .EOF
-
strBuild = strBuild & ![Field1] & ", "
-
.MoveNext
-
Loop
-
End With
-
-
If strBuild <> "" Then MsgBox Left$(strBuild, Len(strBuild) - 2)
-
-
rst.Close
-
Set rst = Nothing
-
End Sub
-
- OUTPUT (String in Msgbox() after adding a New Record):
- hi, hola, hein, bon jour, hallo, New Field1 Value
You are more than welcome.
Sign in to post your reply or Sign up for a free account.
Similar topics
by: Malcolm Cook |
last post by:
I've discovered:
Using "File > Print Preview" in a form's datasheet view with a server Filter
crashes access after previewing...
....that is, unless ServerFilterByForm has been turned off...
|
by: steph |
last post by:
Hi all,
I have an Access2002 form in in datasheet view. Column "CMP" is locked
to user input, instead it is filled automatically by this function:
===
Private Sub Form_BeforeInsert(Cancel As...
|
by: igniztion |
last post by:
Hi,
When I paste several rows into datasheet view in MS Access, does this
trigger a single INSERT with all the rows, or is it counted as one
INSERT statement per row?
Vegard
|
by: Danny J. Lesandrini |
last post by:
-- previously posted on newsgroup :: <microsoft.public.access--
Has anyone else noticed this behavior?
Focus jumping from current cell to upper left in embedded datasheet.
If not, would you be...
|
by: icenemesis |
last post by:
I have a form that searches dynamically based on what criteria the user enters. The resulting query populates a subform in datasheet view.
If I wanted to have a button that would export the...
|
by: curran.george |
last post by:
'add one textbox to form1 with Control Source property = ID
'copy/paste the form_load code below:
'Then open the form and then attempt to sort the datasheet
'crashes 2003, error 3450 Access 2007 -...
|
by: nomvula |
last post by:
hi guys
i need some help to duplicate records on my form datasheet:
here's the example of my form results:
ClientLookup DateCaptured ForecastDate Description ForecastQuantity Forecast Actual
UJ...
|
by: zandiT |
last post by:
hello
i have an access database which ive just put on a shared folder on the network for users to use. i tested it well, exported all the objects in a new database, converted to to an mde file,...
|
by: neosp17 |
last post by:
HI, I have sub form with checkbox as one checkbox column , name, total amount owned. Only one record from the sub form can be ticked (checked)
Question: how to make only one checkbox ticked in sub...
|
by: Charles Arthur |
last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
|
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...
|
by: nemocccc |
last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
|
by: Hystou |
last post by:
There are some requirements for setting up RAID:
1. The motherboard and BIOS support RAID configuration.
2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
|
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...
|
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: 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...
|
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...
| |