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 1330 - 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: 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: 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:
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: emmanuelkatto |
last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud.
Please let me know.
Thanks!
Emmanuel
|
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: 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: 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,...
|
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: 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...
| |