Dear all,
I have a question about ADO in the subform. I know how to use ADO to insert/update/select data into the sigin form, but wehn I try to do it in the form with subform((Datasheet). I don't have any idea how to insert/update/select the recordset data into the subform(Datasheet), especially insert/update. Would someone can give me a idea or sample code to me? Appreciate your help.
OS: windows XP +SP2+ Access 2003+SP2
Database: MS SQL Server 2000+SP4
11 3075
The mainform's properties like recordsource can be referenced with the "Me.recordsource"
For the subform on such a mainform you need: "Me!<subformname>.Form.recordsource"
Nic;o)
Hi Nico,
I'm having trouble putting this together.
This is what I've got: - Me!subFrmTasks.Form.RecordSource = str
And I get this error: Runtime 40036, "Application-defined or object-defined error".
I also tried with using "Me." instead of "Me!", and I got same error code, "Method 'Form' of object '_SubForm' failed"
Any ideas?
Hmm, make sure that "str" contains a valid SQL Select string and also verify that the name of the subform (See under "Other" tab in properties window) is the name used after the Me!
Nic;o)
I've checked both and they are correct, not sure where else to look, I'll keep searching.
R
Perhaps database corruption is the problem.
Try to create a new blank database and use File/Get externaldata/Import to create a new "fresh" copy of the database.
Nic;o)
OK, so I'm not getting anywhere. This is the last thing I have to do on this database before I leave the company!
I've made a new database, reimporting all the tables, queries, forms and modules necessary. Here is what my whole code looks lik, on the On Open event for the main form: - str = "SELECT tblTasks.TaskID, tblTasks.ProjectID, tblTasks.NameID, tblTasks.NameID2, tblTasks.TaskTypeID, tblTasks.Notes, tblTasks.LanguageID, tblTasks.WordCount, tblTasks.Email, tblTasks.AssignDateMonth, tblTasks.AssignDateDay, tblTasks.AssignDateYear, tblTasks.DeadlineMonth, tblTasks.DeadlineDay, tblTasks.DeadlineYear, tblTasks.TaskStatusID, tblTasks.NameID2, tblTasks.ProjectManagerID, tblTasks.DateCreated, tblTasks.PostponedFrom, tblName.PersonEmail, tblName_1.PersonEmail, tblTasks.AssignTime, tblTasks.DeadlineTime, tblTasks.StatusID, tblName.NameTypeID, tblName_1.NameTypeID, tblTasks.EmailSent, tblTasks.UnderstandsSource, tblTasks.TechnicalIssues, tblTasks.StyleGuide, tblTasks.PercentComplete, tblTasks.UpdateFlag, tblTasks.VENotes FROM tblName AS tblName_1 RIGHT JOIN (tblTasks LEFT JOIN tblName ON tblTasks.NameID = tblName.NameID) ON tblName_1.NameID = tblTasks.NameID2 ORDER BY tblTasks.LanguageID;"
-
Me!subfrmTasksOneLine.Form.RecordSource = str
-
Me!subFrmTasks.Form.RecordSource = str
I've checked the subform names, and it's fine. I've made sure that the subform names are accurate, and that the sql code is functional. The Master-Child relatioship is set on the forms themselves (not in code). The subforms are set in tabs, I don't know if that affects anything. I'm getting two distinct problems.
On the line: Me!subfrmTasksOneLine.Form.RecordSource = str, I get nothing, the subform comes up without a recordset (the unpopular #Name?). This is my first time setting a subform recordset through code, so it could be I'm missing something fundamental.
On the next line: Me!subFrmTasks.Form.RecordSource = str, I get the same error as before, "Application-defined or object-defined error". The only difference between these two subforms is that they are put in a tab; subFrmTasks is in the hidden tab. I don't know if that could affect things.
Hmm, looks like the event sequence isn't working OK.
You could try to move the code into the OnCurrent event of the form, that way we're sure that the subforms are loaded.
I'm puzzled why you are setting the recordsource here, as I see no variable part in the query. Why not have the subforms with a "fixed" recordsource ?
Nic;o)
The main form is a project form that opens up from a separate form. Depending on what the Project ID is, these subforms are based off of a different recordsource. I actually didn't post the two recordsource strings, to keep the posting simple.
Did the move to the OnCurrent event work ?
Nic;o)
No, unfortunately it didn't. I don't really know what else to do. I tried the OnCurrent for the main form, now I'm trying it on the subform.
Did the move to the OnCurrent event work ?
Nic;o)
Hmm, ran into this sample where they try to implement transaction processing, but the subform assignment is like we do, but two Set statements are used to assign the recordsource: http://www.tek-tips.com/viewthread.c...1257388&page=7
one for activating the rst (by running a stored procedure) and one to assign the recordset to the subform.
Is that the same way you used for the login form ?
Nic;o)
Sign in to post your reply or Sign up for a free account.
Similar topics
by: deko |
last post by:
I have a form with a subform datasheet - I need code behind the OnDelete
event of the subform:
Private Sub Form_Delete(Cancel As Integer)
'do something that depends on which record is deleted...
|
by: deko |
last post by:
I'd like to be able to do in-cell editing of a datasheet and have other fields
automatically update. I know... the easy answer is to use Excel, but I'm
wondering if I can pull this off in Access...
|
by: ANSWER |
last post by:
I have main form who contains subform in datasheet.
I want to disable (selecting one column and then Ctrl + C).
I just want them to see results in datasheet but not to copy data form
datasheet.
...
|
by: cefrancke |
last post by:
How does Stephen Lebans make the datasheet row color
change by clicking a row's check box field?
I cant find any code associated with the form, and I
cant tell if you have created a class on the...
|
by: sofakingfree |
last post by:
Is there a way to perform actions on the selected records of a
datasheet subform? Actually I know it can be done from a pulldown menu
or a toolbar. But how can you create a button on the form...
|
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: HyBry |
last post by:
I have send mail button assigned to datasheet in subform. Works fine if I want to send mail to one person, but I want it to work if I have multiple selection as well.
code I have now is ...
|
by: RamanS |
last post by:
Hi,
I am creating an inventory management database.
I have three tables in this database, Products, Orders and Order Details.
I have a form Order Entry in which i create an order to be...
|
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: 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:
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: 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: 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...
| |