Running function which gets a form parameter type + Reseting existing field's parameter to null or "

A

Amir

Hello!



I have 2 questions, both referring to a form I am trying to build. Both
questions are written at the end of the message.

I would be grateful if you could answer them.





Form Structure:

------------------

Form Name: frmReceiptEvents

Form Controls (only the relevant ones):

Control Name RowSource

---------------- -------------

ProductKeyInReceipt
ProductKey,ProductName,ProductSupplier,HasDiameter,HasMaterialType (from
tblProducts and tblProductTypes, which are linked, of course)

MaterialType MaterialType (from
tblMaterialTypes)

Diameter





Form Events:

---------------

Private Sub Form_Current()





'AutoFillNewRecord ([Forms]![frmReceiptEvents])

'I Disabled this function using a ' sign, due to an error (Look at question
1).





'A similar code as the following code runs in the ProductKeyInReceipt
AfterUpdate event

If Me!ProductKeyInReceipt.Column(3) = False Then

Me!Diameter.Enabled = False

Me!Diameter.Value = Null

Me!Diameter.Locked = True

Else

Me!Diameter.Enabled = True

Me!Diameter.Locked = False

End If



If Me!ProductKeyInReceipt.Column(4) = False Then

Me!MaterialType.LimitToList = False

Me!MaterialType.Enabled = True

Me!MaterialType.SetFocus

Me!MaterialType.Text = """"

'Here I get an error message (Look at question 2).



Me!ProductKeyInReceipt.SetFocus

Me!MaterialType.Enabled = False

Me!MaterialType.Locked = True

Else

Me!MaterialType.Enabled = True

Me!MaterialType.LimitToList = True

Me!MaterialType.Locked = False

End If



End Sub





Questions:

------------

1.How can I call this function correctly? Function is part of
AutoFillNewRecord module, and it's declaration looks like this:

Function AutoFillNewRecord(F As Form)

Problem is that when I try to call the function as described, I get
a "type mismatch" error. I've tried the following solution, but it didn't
work:



AutoFillNewRecord ("[Forms]![frmReceiptEvents]")



How can I transfer the form's name to the function correctly?





2. Here, at the Me!MaterialType.Text = """" line, I get a
message saying that the property is read only, and cannot be changed.

I want the MaterialType and Diameter commands to be dependant on the
selection in the ProductKeyInReceipt command.

Some of the product types have diameter data, and some of them haven't.
Same rule for MaterialType Data.

Therefore, I want the MaterialType and Diameter commands to:

1. Become enabled / disabled according to the value of the (3) or
(4) column in the ProductKeyInReceipt command

(These are the columns which specify whethear the product has
diameter and material type data, and they can be True or False)

2. Become "Nothing" (null?) if the specified product hasn't a
diameter or material type data. That's important for reports

I am going to build, because I don't want products to appear in
queries which relay on the material type data, just because

a user once made a record with a product which has material type,
then changed the product, and the material type remained for the

new product, even though the new product doesn't suppose to have a
material type. Therefore I need this field to be "nothing" in such cases.





Thank you for reading!
 
A

Amir

As to the function, I solved it using:

AutoFillNewRecord [Forms]![frmReceiptEvents]

instead of

AutoFillNewRecord ([Forms]![frmReceiptEvents])



I still can't solve the 2nd question.

I would be thankful if you could help!



Amir said:
Hello!



I have 2 questions, both referring to a form I am trying to build. Both
questions are written at the end of the message.

I would be grateful if you could answer them.





Form Structure:

------------------

Form Name: frmReceiptEvents

Form Controls (only the relevant ones):

Control Name RowSource

---------------- -------------

ProductKeyInReceipt
ProductKey,ProductName,ProductSupplier,HasDiameter,HasMaterialType (from
tblProducts and tblProductTypes, which are linked, of course)

MaterialType MaterialType (from
tblMaterialTypes)

Diameter





Form Events:

---------------

Private Sub Form_Current()





'AutoFillNewRecord ([Forms]![frmReceiptEvents])

'I Disabled this function using a ' sign, due to an error (Look at question
1).





'A similar code as the following code runs in the ProductKeyInReceipt
AfterUpdate event

If Me!ProductKeyInReceipt.Column(3) = False Then

Me!Diameter.Enabled = False

Me!Diameter.Value = Null

Me!Diameter.Locked = True

Else

Me!Diameter.Enabled = True

Me!Diameter.Locked = False

End If



If Me!ProductKeyInReceipt.Column(4) = False Then

Me!MaterialType.LimitToList = False

Me!MaterialType.Enabled = True

Me!MaterialType.SetFocus

Me!MaterialType.Text = """"

'Here I get an error message (Look at question 2).



Me!ProductKeyInReceipt.SetFocus

Me!MaterialType.Enabled = False

Me!MaterialType.Locked = True

Else

Me!MaterialType.Enabled = True

Me!MaterialType.LimitToList = True

Me!MaterialType.Locked = False

End If



End Sub





Questions:

------------

1.How can I call this function correctly? Function is part of
AutoFillNewRecord module, and it's declaration looks like this:

Function AutoFillNewRecord(F As Form)

Problem is that when I try to call the function as described, I get
a "type mismatch" error. I've tried the following solution, but it didn't
work:



AutoFillNewRecord ("[Forms]![frmReceiptEvents]")



How can I transfer the form's name to the function correctly?





2. Here, at the Me!MaterialType.Text = """" line, I get a
message saying that the property is read only, and cannot be changed.

I want the MaterialType and Diameter commands to be dependant on the
selection in the ProductKeyInReceipt command.

Some of the product types have diameter data, and some of them haven't.
Same rule for MaterialType Data.

Therefore, I want the MaterialType and Diameter commands to:

1. Become enabled / disabled according to the value of the (3) or
(4) column in the ProductKeyInReceipt command

(These are the columns which specify whethear the product has
diameter and material type data, and they can be True or False)

2. Become "Nothing" (null?) if the specified product hasn't a
diameter or material type data. That's important for reports

I am going to build, because I don't want products to appear in
queries which relay on the material type data, just because

a user once made a record with a product which has material type,
then changed the product, and the material type remained for the

new product, even though the new product doesn't suppose to have a
material type. Therefore I need this field to be "nothing" in such cases.





Thank you for reading!
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top