使用Openargs打开表单 [英] Open forms using Openargs

查看:65
本文介绍了使用Openargs打开表单的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有两种形式,frma和frmb,两者都用于输入新记录,并且基于表tblmonth是

,两者都有两个控件,txtmonth和

txtmonthlabela,它们基于表格中的字段。

frma有一个打开frmb的命令按钮。我希望命令buuton传递

txtmonth和txtmonthlabela的值从frma到frmb上的控件

我在frma上的命令按钮上使用此代码:

Private Sub cmdOpenform_Click()

出错时GoTo Err_cmdOpenform_Click


DoCmd.OpenForm" frmb",,,, acFormEdit ,, Me .txtMonth

DoCmd.Close acForm,Me.Name

Exit_cmdOpenform_Click:

退出子


Err_cmdOpenform_Click:

MsgBox Err.Description

恢复Exit_cmdOpenform_Click

结束子


和此代码frmb的onload事件:

Private Sub Form_Load()

如果Len(Me.OpenArgs&"")> 0然后

Me.txtMonth = Me.OpenArgs

Me.txtMonth.SetFocus

结束如果


End Sub


目前的代码只传递txtmonth的值,我想传递

的txtmonthlabela值。另外因为txtmonth在字段上设置了没有

重复属性,所以我收到一条错误消息,说我不能创建新记录,因为它已经存在。 br />
有人可以帮忙吗?

TIA

Tony Williams

解决方案

传递一个字符串作为您的参数,其中包含月份数据+百分号

(或者永远不会是实际值的一部分)+月份标签

数据。然后,在你的OnLoad代码中,解析出两个独立的字符串:

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

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

解决方案

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


这篇关于使用Openargs打开表单的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆