OPENARGS IN OPEN FOR, METHOD

  • Thread starter Thread starter LIORA
  • Start date Start date
L

LIORA

How can I enter some arguments in the OPENARGS
I want to move a value OF two fields from A SELECTED
RECORD ON A form -to a second form which should open in a
add mode - and set those field value to the new record at
the secound form
I can move value of one field by the OPENARGS - How can I
move two value???
I hope you understand

liora
 
DoCmd.OpenForm "MyForm", OpenArgs:="Value1;Value2"

Private Sub Form_Load()
Dim str1 As String
Dim str2 As String
Dim lngPos As Long

lngPos = Instr(Me.OpenArgs, ";")
If lngPos > 0 Then
str1 = Trim(Left(Me.OpenArgs, lngPos - 1))
str2 = Trim(Mid(Me.OpenArgs, lngPos + 1))
End If
End Sub
 
thanks
after I assign the str1 and str2 - I wand to enter it to
the files or the form that open in add mode I try to:

me.hunm=str1
me.batch=str2

I recieve error message- "You can not assign value to this
object"

why , how can I do it??

liora
 
When are you assigning this? Form_Open would be too early.

What is the data type of these fields? For example, if batch is a number,
you may need to use:
me.batch = CLng(str2)

Are you moving the form to a new record before doing this, or overwriting an
existing record?
 
I WANT THAT THE FORM WITH THE NEW RECORD WILL OPENDED WITH
THESE ASSIGNED FIELDS - WHAT THE BEST WAY TO DO THIS??
 
liora, I am not deaf (despite your shouting), but I have still not heard
anything about the data types, so you will have to sor this out for
yourself.

As a general guide, you can do somethig like this:

Private Sub Form_Load()
If Len(Nz(Me.OpenArgs, vbNullString)) > 0 Then
If Not Me.NewRecord Then
RunCommand acCmdRecordsGoToNew
Me.Surname = Me.OpenArgs
End If
End If
End Sub
 
Back
Top