I have two forms, frma and frmb, both are for inputting new records and are
based on a table, tblmonth, both have two controls, txtmonth and
txtmonthlabela which are based on the fields in the table.
frma has a command button that opens frmb. I want the command buuton to pass
the value of txtmonth and txtmonthlabela from frma to the controls on frmb
I am using this code on the command button on frma:
Private Sub cmdOpenform_Click()
On Error GoTo Err_cmdOpenform_Click
DoCmd.OpenForm "frmb", , , , acFormEdit, , Me.txtMonth
DoCmd.Close acForm, Me.Name
Exit_cmdOpenform_Click:
Exit Sub
Err_cmdOpenform_Click:
MsgBox Err.Description
Resume Exit_cmdOpenform_Click
End Sub
and this code on the onload event of frmb:
Private Sub Form_Load()
If Len(Me.OpenArgs & "") > 0 Then
Me.txtMonth = Me.OpenArgs
Me.txtMonth.SetFocus
End If
End Sub
The code at the moment only passes the value of txtmonth and I want to pass
the value of txtmonthlabela as well. Also because txtmonth has the no
duplicates property set on the field I get an error message to say I can't
create the new record because it already exists.
Can anyone help?
TIA
Tony Williams 5 9191
Pass a string as your argument that contains the month data + a percent sign
(or something that would never be part of an actual value) + month label
data. Then, in your OnLoad code, parse out the two separate Strings:
Dim i As Integer
Dim s As String
s = CStr(Me.OpenArgs)
i = InStr(1, s, "%")
Me.txtmonth = Left$(s, i - 1)
Me.txtmonthlabela = Mid$(s, i + 1)
Darryl Kerkeslager
Darryl I'm a newbie so that went a bit over my head.
Does this code go in the onclick expression or in the onload? How do I get
pick up both values from the first form? In other words how does your code
relate to the code I posted? Any ideas on my second part of my question?
Thanks for your help
Tony
"Darryl Kerkeslager" <Ke*********@comcast.net> wrote in message
news:Bv********************@comcast.com... Pass a string as your argument that contains the month data + a percent
sign (or something that would never be part of an actual value) + month label data. Then, in your OnLoad code, parse out the two separate Strings:
Dim i As Integer Dim s As String s = CStr(Me.OpenArgs) i = InStr(1, s, "%") Me.txtmonth = Left$(s, i - 1) Me.txtmonthlabela = Mid$(s, i + 1)
Darryl Kerkeslager
Hi Tony,
Darryl's code goes into the Form_Load event. I have made an example for your
code, see below. The code in the cmdOpenForm_Click procedure assumes that
both values are actually entered and that these do not contain the %
character (as Darryl already suggested).
HJ
frma: cmdOpenForm_Click
Private Sub cmdOpenForm_Click()
On Error GoTo Err_cmdOpenform_Click
Dim strArgs As String
strArgs = Me.txtMonth & "%" & Me.txtMonthLabelA
DoCmd.OpenForm "frmb", , , , acFormEdit, , strArgs
DoCmd.Close acForm, Me.Name
Exit_cmdOpenform_Click:
Exit Sub
Err_cmdOpenform_Click:
MsgBox Err.Description
Resume Exit_cmdOpenform_Click
End Sub
frmb: Form_Load
Private Sub Form_Load()
If Len(Me.OpenArgs & "") > 0 Then
Dim i As Integer
Dim s As String
s = CStr(Me.OpenArgs)
i = InStr(1, s, "%")
Me.txtMonth = Left$(s, i - 1)
Me.txtMonthLabelA = Mid$(s, i + 1)
Me.txtMonth.SetFocus
End If
End Sub
Thanks HJ, that's a great help for me
Tony
"HJ" <hj********@spamhotmail.com> wrote in message
news:41***********************@news.xs4all.nl... Hi Tony,
Darryl's code goes into the Form_Load event. I have made an example for
your code, see below. The code in the cmdOpenForm_Click procedure assumes that both values are actually entered and that these do not contain the % character (as Darryl already suggested).
HJ
frma: cmdOpenForm_Click
Private Sub cmdOpenForm_Click() On Error GoTo Err_cmdOpenform_Click
Dim strArgs As String strArgs = Me.txtMonth & "%" & Me.txtMonthLabelA
DoCmd.OpenForm "frmb", , , , acFormEdit, , strArgs DoCmd.Close acForm, Me.Name
Exit_cmdOpenform_Click: Exit Sub
Err_cmdOpenform_Click: MsgBox Err.Description Resume Exit_cmdOpenform_Click
End Sub
frmb: Form_Load
Private Sub Form_Load()
If Len(Me.OpenArgs & "") > 0 Then Dim i As Integer Dim s As String s = CStr(Me.OpenArgs) i = InStr(1, s, "%") Me.txtMonth = Left$(s, i - 1) Me.txtMonthLabelA = Mid$(s, i + 1) Me.txtMonth.SetFocus End If
End Sub
1. In frma, declare a string variable srtDateMonth, and pass it with the
following value = Me.txtmonth.Value & "," & Me.txtmonthlabela.Value. In
frmb, parse the srtDateMonth value into the two values using the InStr and
Mid functions.
2. In the table, set allow duplicates "yes" for the txtmonth field and
create a joint Primary Key on txtmonth and the existing primary key.
--
Tony D'Ambra
Web Site: aadconsulting.com
Web Blog: accessextra.net
"Tony Williams" <tw@tcpinvalid.com> wrote in message
news:cp**********@titan.btinternet.com... I have two forms, frma and frmb, both are for inputting new records and are based on a table, tblmonth, both have two controls, txtmonth and txtmonthlabela which are based on the fields in the table. frma has a command button that opens frmb. I want the command buuton to pass the value of txtmonth and txtmonthlabela from frma to the controls on frmb I am using this code on the command button on frma: Private Sub cmdOpenform_Click()
DoCmd.OpenForm "frmb", , , , acFormEdit, , Me.txtMonth DoCmd.Close acForm, Me.Name Exit_cmdOpenform_Click: Exit Sub
Err_cmdOpenform_Click: MsgBox Err.Description Resume Exit_cmdOpenform_Click End Sub
and this code on the onload event of frmb: Private Sub Form_Load() If Len(Me.OpenArgs & "") > 0 Then Me.txtMonth = Me.OpenArgs Me.txtMonth.SetFocus End If
End Sub
The code at the moment only passes the value of txtmonth and I want to pass the value of txtmonthlabela as well. Also because txtmonth has the no duplicates property set on the field I get an error message to say I can't create the new record because it already exists. Can anyone help? TIA Tony Williams
This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics
by: Shyguy |
last post by:
I have two forms that both open the same (3rd) form.
The third form does the same thing, but a little differently depending
on which form it is opened from. Is there a way I can check which
form...
|
by: Tony Williams |
last post by:
I have two forms, frma and frmb, both are for inputting new records and are
based on a table, tblmonth, both have two controls, txtmonth and
txtmonthlabela which are based on the fields in the...
|
by: beowulfs |
last post by:
Here's what I've got:
I've got a form with combo boxes. you can select already existing
company names or type in new ones. if you type in a new one, it
prompts you to double click the combo...
|
by: fredindy |
last post by:
I'm having trouble figuring out what I need to do here. Basically, I
want to pull data from several different tables and send them to a form
using open args. However, the form that is being fed...
|
by: Del |
last post by:
I have a form call frmMMD-PCKR. This form has seven buttons, each
button represents a part. When I click on any of the buttons they open
another form called frmTallyTagMMDPCKR.
On the...
|
by: Dave |
last post by:
Access 2002...I need to open a popup at the location of a mouse
dblclick. Can anyone help with this? I can get the mouse X & Y, but
I'm not sure how to open a form in a specific location by code....
|
by: vanlanjl |
last post by:
Okay lets see if I can do this with out confusing myself or others. First I will give ALL the details then state my problem and request at the bottom.
Tables:
tblContacts
ID
Company
LastName...
|
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: nemocccc |
last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
|
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:
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: agi2029 |
last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
| |