Can Forms / Controls be controlled remotely?
From: wiz (wizbang7777_at_yahoo.com)
Date: 11/12/04
- Previous message: Norm Cook: "Re: DAO instructions"
- Messages sorted by: [ date ] [ thread ]
Date: Thu, 11 Nov 2004 18:06:43 -0600
Greetings,
I'm not even sure if what I am trying to do is even possible.
The following code works except for the lines with the ???? in front.
The ???? indicates where this code works in a Module ([i]code that is
outside the forms class[/i]) locally in the Access program but not
outside of the program in the separate VB control program I am working
in.
The table/recordset operations work just fine. I just am trying, once I
open a particular Form, to populate the form with some data.... plus
some other stuff but first things first.
------ CODE ------
Sub Main()
Dim dbs As Database
Dim rst As Recordset
Dim frm As Form
Dim strDatabase As String
Dim strA, strB As String
strDatabase = "C:\DBTest\Concept.mdb"
Set dbs = DBEngine.Workspaces(0).OpenDatabase(strDatabase)
Set rst = dbs.OpenRecordset("Table1")
With rst
.MoveFirst
strA = !ID
strB = !Field1
End With
DoCmd.OpenForm "Frm_TestForm", acNormal
???? Set frm = Forms!Frm_TestForm
???? frm!txtControlTest.Text = "foobar"
DoCmd.Close acForm, "Frm_TestForm"
rst.Close
dbs.Close
End Sub
-----------------
When the code runs it opens the database and recordset just fine. The
variables contain the correct information and the DoCmd.OpenForm works
(although I don't understand why... unless it's because within this
procedure opening a database has somehow set up an "environment" that
the DoCmd knows about.
The program breaks, hiccups when it comes to theSet frm =
Forms!Frm_TestForm statement Runtime Error 13 IT does not know about
"Forms!" I was HOPING that since the DoCmd could open the form that
"Froms!" would work too! LOL
Since I can't get past the Set statement I don't know if the next
statement would bomb also.
Continuing on, if I comment the two questionable lines the form closes
and the procedure exits normally.
Does anyone know how the syntax, (if it's even possible) necessary to
open a Form and then access the controls and even public sub/functions
in the form class.
I tried another approach THAT DID NOT WORK AT ALL
------ CODE ------
Set appAccess = CreateObject("Access.Application")
appAccess.OpenCurrentDatabase ("C:\DBTest\Concept.mdb")
appAccess.DoCmd.OpenForm "Frm_TestForm"
-------------------
In this next example, the Form never opened up. I was thinking that
somehow that this might have allowed me to get into the Forms
Objects/Collections and could somehow be referenced.
If someone has another approach entirely I'm open to that as well ;)
Gee, I hope I haven't confused this issue.
many thanks in advance,
wiz
PS
The following code section are various code snippets of the
functionality that I use in Access that I would like to do remotely
while using VB to control the Access application. I don't know if it's
even close to being possible to achieve that level of control. (I have
in remote controlling Excell spreadsheets, down to the cell and cell
property level but the mechanism is slightly different than working
with Access)
------ CODE SNIPPETS ---------
Forms!Frm_ProgressForm.frm_display_progress inLevel
Forms.Caption = inCaption
Forms![Frm_Appointments]![lstCurrentAppointments].Requery
If CalFormIsLoaded("Frm_CalendarAppointments") Then
Forms![Frm_CalendarAppointments].resetAppointmentsCalendar inMonth
End If
If IsLoaded("Frm_ProgressForm") = True Then
For intIndex = 1 To inNumber
strLocation = "chk" & Trim(Str(intIndex))
Forms.Visible = True
strLocation = "lbl" & Trim(Str(intIndex))
Forms.Visible = True
Next intIndex
------------------
-- This is an automatic signature of MesNews. Site : http://mesnews.no-ip.com
- Previous message: Norm Cook: "Re: DAO instructions"
- Messages sorted by: [ date ] [ thread ]