I have a single form that I want to make as generic as possible. The
form contains a Calendar control.
Using OpenArgs I pass values from the form that's calling the calendar,
and the field the calendar should write to. I do this so I can use the
same calendar form throughout my database.
Does anyone know how to pass this info back to the form that called it?
I'm trying to set the value of the control on a form using a Submit
button on the calendar form. My code looks like this:
Private Sub Submit_Click()
On Error Resume Next
Dim strForm, strField As String
strFormName = Left(Me.OpenArg s, InStr(Me.OpenAr gs, "|") - 1)
strFieldName = Mid(Me.OpenArgs , InStr(Me.OpenAr gs, "|") + 1)
X = "Forms! " & strFormName & "." & strFieldName & ".Value =
Me.Calendar0.Va lue"
DoCmd.Close
End Sub
When I break it, the variable X has the proper syntax I need but
there's no way to run X. I need to figure out how to set
Forms! (strFormName) . (strFieldName) .Value = Me.Calendar0.Va lue
Anyone know if it can be done? 5 7977
There's an example of this in Access Developer's Handbook... no nasty
ActiveX muck to deal with, either.
The way you get the data into the form in question is to cause a
control on the form you wish to enter data into call a function that
opens the calendar. Then the calendar passes a value to the function,
which passes it to your form.
IIRC, ADH's code does something like this:
1. opens the Calendar form
2. waits for the user to select a value (ie does nothing)
3. when the user closes the calendar, the date selected gets passed to
a function's return value.
4. the value of the function is passed to the control in question.
IOW, someone has already done this, and quite well. Unless you're into
reinventing the wheel, get a copy of the book.
in a nutshell, I'd use the ADH version. It works well, and you spend
zero time/money developing your own solution.
I know that doesn't directly answer your question, and sounds like a
blatant sales pitch to boot. But I don't think any serious Access
developer should be without it. If you don't believe me, read the
reviews for yourself at Amazon. The only caveat to the book is that if
you don't understand VB, you won't understand most of the book. It's
definitely a beginner book (and they say that in the
Foreword/Introduction).
Nevermind, I got it. I had to set up a variable as type Form.
Here's what I came up with:
Private Sub Submit_Click()
On Error Resume Next
Dim strFormName, strFieldName As String
Dim Frm As Form
Dim Ctl As TextBox
strFormName = Left(Me.OpenArg s, InStr(Me.OpenAr gs, "|") - 1)
strFieldName = Mid(Me.OpenArgs , InStr(Me.OpenAr gs, "|") + 1)
Set Frm = Forms(strFormNa me)
Set Ctl = Frm.Controls(st rFieldName)
Ctl = Me.Calendar0.Va lue
DoCmd.Close
End Sub
HTH,
Jana ma********@gmai l.com wrote in
news:11******** **************@ i39g2000cwa.goo glegroups.com: I have a single form that I want to make as generic as possible. The form contains a Calendar control.
Does anyone know how to pass this info back to the form that called it?
I'm trying to set the value of the control on a form using a Submit button on the calendar form.
Anyone know if it can be done?
download the datepicker discussed on this page and study the way
Brendan Kidwell did it. Or just borrow his form and code. http://www.mvps.org/access/forms/frm0057.htm
--
Bob Quintal
PA is y I've altered my email address. ADezii 8,834
Recognized Expert Expert
I have a single form that I want to make as generic as possible. The
form contains a Calendar control.
Using OpenArgs I pass values from the form that's calling the calendar,
and the field the calendar should write to. I do this so I can use the
same calendar form throughout my database.
Does anyone know how to pass this info back to the form that called it?
I'm trying to set the value of the control on a form using a Submit
button on the calendar form. My code looks like this:
Private Sub Submit_Click()
On Error Resume Next
Dim strForm, strField As String
strFormName = Left(Me.OpenArg s, InStr(Me.OpenAr gs, "|") - 1)
strFieldName = Mid(Me.OpenArgs , InStr(Me.OpenAr gs, "|") + 1)
X = "Forms! " & strFormName & "." & strFieldName & ".Value =
Me.Calendar0.Va lue"
DoCmd.Close
End Sub
When I break it, the variable X has the proper syntax I need but
there's no way to run X. I need to figure out how to set
Forms! (strFormName) . (strFieldName) .Value = Me.Calendar0.Va lue
Anyone know if it can be done?
This is a drastic alternative to your approach, but give it a try and see what you think: 'Declare a Public variable of type Control
Public ctlMyControl As Control 'In the calling Form explicitly initiate it and list the calling Form and field
'which will contain the return value. The only change you'll make.
Private Sub Form_Open(Cance l As Integer)
Set ctlMyControl = Forms![frmTest]![txtCalendarValu e]
End Sub 'Your new Submit Button code
Private Sub Submit_Click()
On Error Resume Next
ctlMyControl.Va lue = Me![Calendar1].Value
Set ctlMyControl = Nothing
DoCmd.Close
End Sub
This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
by: Paul |
last post by:
I want to use sessions to cover myself in case the user switches off cookies
so I am passing the session ID manually through a hidden input field. This
is what I have so far.
index.php page contains:
<?php
$_SESSION = "";
$_SESSION = "";
|
by: Paul |
last post by:
Hmmm, didn't seem to work. I have set session.use_cookies = 1 and
session.use_trans_sid = 1 in my php.ini file. Index.php contains:
----------------------------------------------------------------------------
<?php
ini_set("session.use_cookies", "off");
ini_set("session.use_trans_sid", "on");
session_start();
$_SESSION = "";
$_SESSION = "";
echo "<form method='POST' action='login.php'>
|
by: domeceo |
last post by:
can anyone tell me why I cannot pass values in a setTimeout function
whenever I use this function it says "menu is undefined" after th
alert.
function imgOff(menu, num) {
if (document.images) {
document.images.src = eval("mt" +menu+ ".src")
}
alert("imgOff_hidemenu");
hideMenu=setTimeout('Hide(menu,num)',500);
|
by: veganeater |
last post by:
Hi Everyone,
I was wondering if there was a way to pass a variable to a popup window. The
purpose is make it so when a user clicks on a specific region/link of the
glossary page, a popup opens with the related description. This is done and
is obviously not a concern. However, now I would like to make it so the
corresponding row becomes highlighted (changes background colour via DOM).
I imagine it can be done, but I'm at a loss for...
|
by: sofakingfree |
last post by:
I keep getting an invalid property assignment error when tring to
reference a subform.
All I am trying to do is substitute this:
Forms!!.SetFocus
for this:
FormAndSubForm.SetFocus
| |
by: Johnny |
last post by:
I'm a rookie at C# and OO so please don't laugh! I have a form
(fclsTaxCalculator) that contains a text box (tboxZipCode) containing a zip
code. The user can enter a zip code in the text box and click a button to
determine whether the zip code is unique. If the zip code is not unique,
another form/dialog is displayed (fclsLookup) - lookup form/dialog. The zip
code is passed to the lookup form/dialog by reference. I then load a...
|
by: michael |
last post by:
let me keep it clean, quick and simple.
I am passing a variable into another window and am reassigning the
value on the new page -
window.document...value = opener.document.
....value
and am wanting to then use this value within an element of a form on
the current page -
|
by: Deano |
last post by:
Apparently you can only do this with one value i.e Call
MyAssetLocationZoom(Me!txtLocation, "Amend data")
This runs;
Public Sub MyAssetLocationZoom(ctl As Control, formName As String)
On Error GoTo err_zoom
strFormName = formName
|
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look !
Part I. Meaning of...
|
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it.
First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
|
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth.
The Art of Business Website Design
Your website is...
| |
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
|
by: conductexam |
last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one.
At the time of converting from word file to html my equations which are in the word document file was convert into image.
Globals.ThisAddIn.Application.ActiveDocument.Select();...
|
by: adsilva |
last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
|
by: 6302768590 |
last post by:
Hai team
i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
|
by: muto222 |
last post by:
How can i add a mobile payment intergratation into php mysql website.
|
by: bsmnconsultancy |
last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...
| |