AutoFillNewRecord type mismatch

tscotti

Registered User.
Local time
Today, 17:04
Joined
Aug 15, 2004
Messages
47
I'm using Microsoft's AutoFillNewRecord function found here http://support.microsoft.com/kb/210236 that you may already be familiar with.

The problem is that I get a type mismatch error when using it with sub forms.

My main form is "Products" and I want it to use the function within a subform called "Transactions".

I've tried various syntax but nothing works! The last I've tried is =AutoFillNewRecord(Forms!frmProducts!frmTransactions) in the OnCurrent property of the main form "Products".

Can anyone help?

Thanks, in advance, for any help offered.
 
Type Mismatch is not a syntax error, but rather exactly what it says it is. You're trying to fill one data type with another data type. You can't fill a numeric data type with text, you can't fill a boolean data type with numbers, etc.

Make sure the source and destination data types are exactly the same. By that, I mean don't fill an integer with a single or a double, etc. Yes, those are both numbers, but the data types are not equal.
 
Moniker,

Thank you for responding.

I'm just trying to use the AutoFillNewRecord function in a subform from the main form.

If I just open the subform, it works! If I access the subform from within the main form, it doesn't.

I'm not transferring information from one form to another.

Tony
 
Hey tscotti,

I'll take a shot at it1;)


change this:
=AutoFillNewRecord(Forms!frmProducts!frmTransactions)

to this:
=AutoFillNewRecord(Forms![frmProducts]![frmTransactions].Form)

If frmTransactions is a subform, then maybe it's puking because .Form is not at the end of it to indentify it as a subform

HTH,
Shane
 
Hey ShaneMan,

Thanks for your answer.

I tried it and I'm no longer getting the "type mismatch" error.

However, it is not autofilling!

Could it be that defined fields to autofill need to be referenced differently?

Thanks again for your help.

Tony
 
Hey ShaneMan,

Thanks for your answer.

I tried it and I'm no longer getting the "type mismatch" error.

However, it is not autofilling!

Could it be that defined fields to autofill need to be referenced differently?

Thanks again for your help.

Tony

Your welcome. I looked over the MS code at the link you provided and it looks like you would need to reference differently since your doing this is on a subform. In the DefaultValue you would need to reference the parent form and then the control name. ie DefaultValue Forms![ParentFormName]![ControlName]

HTH,
Shane
 
Hi Tony,

I don't think you understood what Moniker meant.

Please refer to your table column/field datatypes, make sure that both the Tables "Products" and "Transactions" match.

I'm using Microsoft's AutoFillNewRecord function found here http://support.microsoft.com/kb/210236 that you may already be familiar with.
The problem is that I get a type mismatch error when using it with sub forms.
My main form is "Products" and I want it to use the function within a subform called "Transactions".
I've tried various syntax but nothing works! The last I've tried is =AutoFillNewRecord(Forms!frmProducts!frmTransactions) in the OnCurrent property of the main form "Products".
Can anyone help?
Thanks, in advance, for any help offered.
 
Shaneman,

It still is not working. I've tried different syntax variations for the default value, the last one being [Forms]![frmProducts]![frmTransactions]![Size1Amt].

Please suggest something else! :)

Tony
 
Shaneman,

It still is not working. I've tried different syntax variations for the default value, the last one being [Forms]![frmProducts]![frmTransactions]![Size1Amt].

Please suggest something else! :)

Tony

Tony,

I thought you said frmTransactions is your subforms name. If it is then you would not be calling correctly. If I remember what the code said to do, then you need to put the call in the DefaultValue property of the control on the subform (frmTransactions) and your call would be for the control on the parent form (main form. Products I believe is what you said the parents form name is). Let's say the control on the parent form is Text1 and you want the value from Text1 to go into a control on the subform then in the DefaultValue of the control on the subform you would put:
=Forms![Products]![Text1]. Have you tried that? Am I understanding what you are wanting to do?
 
Hi Shane,

Once again thank you for your help and patience.

Yes, Products is the main form and Transactions is one of the subforms.

If this helps, within the main Products form there are three subforms including Transactions.

The default value is defined as you say on the control in the Transactions subform.

It works if I open just the subform by itself.

On the plus side, I'm not getting "type mismatch" errors.
 
Hi Tony,

Until we get the reply "DataType" is correct. There will be no suggestion.

Do check the primary keys of all tables and the relationships.

What the code does is to copy the last record into the new record.

This include the Primary Keys!

Anyone? please? :o
 
UncleJoe,

I appreciate what you're saying but all I want to do is copy the values from the previous record into a new one from within the same form.

I do not want to copy values from the parent form to the subform.

As I've said, if I configure the AutoFillNewRecords for the Transactions form alone, it works.

But Transactions is a subform within the Products main form.

When I access Transactions from within Products, it doesn't work.

So this is why I fail to understand your argument if it works on its own - I must be missing your point due - please excuse my ignorance.

Regards,

Tony
 
Hi Tony,

The code will only work for a stand alone form. Changes are needed further for the code to work. So have you check?

You need to check the subform RecordSource "DataType" on the column/field of your Transactions Table and also check the Primary key "Index = No" or "Yes (Duplicates OK)". And make sure the tables relationships are correct.

For some unknown or strange reasons, the subform recordsource of that table, it created a primary key Index = "Yes (No Duplicates)".

I have created similar setup of two tables, one with no duplicates and the other table with Yes duplicates OK.

When i created a Main Form and a Subform, the one in the subform, the table column/field with Yes(duplicates OK) it became Yes (No Duplicates).

This will cause an error when code tries to insert a same record.

UncleJoe,

I appreciate what you're saying but all I want to do is copy the values from the previous record into a new one from within the same form.

I do not want to copy values from the parent form to the subform.

As I've said, if I configure the AutoFillNewRecords for the Transactions form alone, it works.

But Transactions is a subform within the Products main form.

When I access Transactions from within Products, it doesn't work.

So this is why I fail to understand your argument if it works on its own - I must be missing your point due - please excuse my ignorance.

Regards,

Tony
 

Users who are viewing this thread

Back
Top Bottom