New record in a datasheet?

R

Rolf Rosenquist

I have an order form with a datasheet-subform, where the order specification
is made. The products are selected in a combo box. Now there are too many
products to choose from, so I would like to let the user choose products a
little easier.

In another form, showing products and suppliers, I can let him first choose
the supplier and then from there, choose the right product. But I cannot
figure out how to take this product-ID and put it into the already open
datasheet-subform as a new record.

Can anyone help?
/ Rolf
 
A

Allen Browne

In the AfterUpdate event proecdure of the ProductID in the 2nd form, include
this line of code:
Forms.[Form1].[Sub1].[Form].[ProductID] = Me.[ProductID]

That assumes:
- The other form is called "Form1".
- Its subform is named "Sub1".
- The other form is still open.
- The other form has the correct record selected in the subform.
 
R

Rolf Rosenquist

Something went wrong here. I did get a message that says, when I translate
to english, something like: "The object does not support the property or
method". This happens independent of if the code is placed in the forms
After_update or in a click event for a new button.

Your 3 first mentioned assumes are right. To the last one, the cursor stands
on the row for a new record in the datasheet.
The same happens if the cursor is placed on an old record (even if that was
not the intention).

/ Rolf



Allen Browne said:
In the AfterUpdate event proecdure of the ProductID in the 2nd form, include
this line of code:
Forms.[Form1].[Sub1].[Form].[ProductID] = Me.[ProductID]

That assumes:
- The other form is called "Form1".
- Its subform is named "Sub1".
- The other form is still open.
- The other form has the correct record selected in the subform.

--
Allen Browne - Microsoft MVP. Perth, Western Australia.

Reply to group, rather than allenbrowne at mvps dot org.

Rolf Rosenquist said:
I have an order form with a datasheet-subform, where the order
specification
is made. The products are selected in a combo box. Now there are too many
products to choose from, so I would like to let the user choose products a
little easier.

In another form, showing products and suppliers, I can let him first
choose
the supplier and then from there, choose the right product. But I cannot
figure out how to take this product-ID and put it into the already open
datasheet-subform as a new record.

Can anyone help?
/ Rolf
 
A

Allen Browne

To debug this, open the Immediate Window (press Ctrl+G), and enter the
reference gradually, until you get it. For example:
? Forms!Form1.Name
That should return "Form1".

Then try:
? Forms!Form1!Sub1.Name
That should return Sub1. If it does not, check the Name property of the
subform control. It may be different from the name of the form loaded into
the control (i.e. its SourceObject).

Once that's right, try:
? Forms.[Form1].[Sub1].[Form].[ProductID]
To see if you get the value of the ProductID, and so on.

--
Allen Browne - Microsoft MVP. Perth, Western Australia.

Reply to group, rather than allenbrowne at mvps dot org.

Rolf Rosenquist said:
Something went wrong here. I did get a message that says, when I translate
to english, something like: "The object does not support the property or
method". This happens independent of if the code is placed in the forms
After_update or in a click event for a new button.

Your 3 first mentioned assumes are right. To the last one, the cursor
stands
on the row for a new record in the datasheet.
The same happens if the cursor is placed on an old record (even if that
was
not the intention).

/ Rolf



Allen Browne said:
In the AfterUpdate event proecdure of the ProductID in the 2nd form, include
this line of code:
Forms.[Form1].[Sub1].[Form].[ProductID] = Me.[ProductID]

That assumes:
- The other form is called "Form1".
- Its subform is named "Sub1".
- The other form is still open.
- The other form has the correct record selected in the subform.

--
Allen Browne - Microsoft MVP. Perth, Western Australia.

Reply to group, rather than allenbrowne at mvps dot org.

Rolf Rosenquist said:
I have an order form with a datasheet-subform, where the order
specification
is made. The products are selected in a combo box. Now there are too many
products to choose from, so I would like to let the user choose
products a
little easier.

In another form, showing products and suppliers, I can let him first
choose
the supplier and then from there, choose the right product. But I
cannot
figure out how to take this product-ID and put it into the already open
datasheet-subform as a new record.

Can anyone help?
/ Rolf
 
R

Rolf Rosenquist

The names of the forms come out as they should, but when I come to
ProductID, I get the same message as before. I also tried another fieldname,
the registered bar code that also is unique, but got the same result: "The
object does not support the property or method".

/ Rolf




Allen Browne said:
To debug this, open the Immediate Window (press Ctrl+G), and enter the
reference gradually, until you get it. For example:
? Forms!Form1.Name
That should return "Form1".

Then try:
? Forms!Form1!Sub1.Name
That should return Sub1. If it does not, check the Name property of the
subform control. It may be different from the name of the form loaded into
the control (i.e. its SourceObject).

Once that's right, try:
? Forms.[Form1].[Sub1].[Form].[ProductID]
To see if you get the value of the ProductID, and so on.

--
Allen Browne - Microsoft MVP. Perth, Western Australia.

Reply to group, rather than allenbrowne at mvps dot org.

Rolf Rosenquist said:
Something went wrong here. I did get a message that says, when I translate
to english, something like: "The object does not support the property or
method". This happens independent of if the code is placed in the forms
After_update or in a click event for a new button.

Your 3 first mentioned assumes are right. To the last one, the cursor
stands
on the row for a new record in the datasheet.
The same happens if the cursor is placed on an old record (even if that
was
not the intention).

/ Rolf



Allen Browne said:
In the AfterUpdate event proecdure of the ProductID in the 2nd form, include
this line of code:
Forms.[Form1].[Sub1].[Form].[ProductID] = Me.[ProductID]

That assumes:
- The other form is called "Form1".
- Its subform is named "Sub1".
- The other form is still open.
- The other form has the correct record selected in the subform.

--
Allen Browne - Microsoft MVP. Perth, Western Australia.

Reply to group, rather than allenbrowne at mvps dot org.

I have an order form with a datasheet-subform, where the order
specification
is made. The products are selected in a combo box. Now there are too many
products to choose from, so I would like to let the user choose
products a
little easier.

In another form, showing products and suppliers, I can let him first
choose
the supplier and then from there, choose the right product. But I
cannot
figure out how to take this product-ID and put it into the already open
datasheet-subform as a new record.

Can anyone help?
/ Rolf
 
A

Allen Browne

Okay, so the ProductID is the problem.

Is there a space in the name, e.g.:
? Forms.[Form1].[Sub1].[Form].[Product ID]

Is there some other kind of object with this name?
? TypeName(Forms.[Form1].[Sub1].[Form].[ProductID])

That's the process to debug what's going on.

--
Allen Browne - Microsoft MVP. Perth, Western Australia.

Reply to group, rather than allenbrowne at mvps dot org.

Rolf Rosenquist said:
The names of the forms come out as they should, but when I come to
ProductID, I get the same message as before. I also tried another
fieldname,
the registered bar code that also is unique, but got the same result: "The
object does not support the property or method".

/ Rolf




Allen Browne said:
To debug this, open the Immediate Window (press Ctrl+G), and enter the
reference gradually, until you get it. For example:
? Forms!Form1.Name
That should return "Form1".

Then try:
? Forms!Form1!Sub1.Name
That should return Sub1. If it does not, check the Name property of the
subform control. It may be different from the name of the form loaded
into
the control (i.e. its SourceObject).

Once that's right, try:
? Forms.[Form1].[Sub1].[Form].[ProductID]
To see if you get the value of the ProductID, and so on.

--
Allen Browne - Microsoft MVP. Perth, Western Australia.

Reply to group, rather than allenbrowne at mvps dot org.

Rolf Rosenquist said:
Something went wrong here. I did get a message that says, when I translate
to english, something like: "The object does not support the property
or
method". This happens independent of if the code is placed in the
forms
After_update or in a click event for a new button.

Your 3 first mentioned assumes are right. To the last one, the cursor
stands
on the row for a new record in the datasheet.
The same happens if the cursor is placed on an old record (even if that
was
not the intention).

/ Rolf



"Allen Browne" <[email protected]> skrev i meddelandet
In the AfterUpdate event proecdure of the ProductID in the 2nd form,
include
this line of code:
Forms.[Form1].[Sub1].[Form].[ProductID] = Me.[ProductID]

That assumes:
- The other form is called "Form1".
- Its subform is named "Sub1".
- The other form is still open.
- The other form has the correct record selected in the subform.


I have an order form with a datasheet-subform, where the order
specification
is made. The products are selected in a combo box. Now there are too
many
products to choose from, so I would like to let the user choose
products
a
little easier.

In another form, showing products and suppliers, I can let him first
choose
the supplier and then from there, choose the right product. But I
cannot
figure out how to take this product-ID and put it into the already open
datasheet-subform as a new record.

Can anyone help?
/ Rolf
 
R

Rolf Rosenquist

No, there is no space inside.
The ?TypeName.... delivers the same error as before.

In the Product form I have a button to bring the ProdID to the datasheet in
the subform of another main form. The click event of this button has the
following row

Forms.[Order].[OrderSpec].[Form].[ProdID] = Me.[ProdID]

With help of a stop command just before, I can see that after this row, the
cursor goes right down to the error handling and gives the message. When I
place the cursor above Me.[ProdID] I see the real value of 112 or whatever
is right for that product.

/ Rolf



Allen Browne said:
Okay, so the ProductID is the problem.

Is there a space in the name, e.g.:
? Forms.[Form1].[Sub1].[Form].[Product ID]

Is there some other kind of object with this name?
? TypeName(Forms.[Form1].[Sub1].[Form].[ProductID])

That's the process to debug what's going on.

--
Allen Browne - Microsoft MVP. Perth, Western Australia.

Reply to group, rather than allenbrowne at mvps dot org.

Rolf Rosenquist said:
The names of the forms come out as they should, but when I come to
ProductID, I get the same message as before. I also tried another
fieldname,
the registered bar code that also is unique, but got the same result: "The
object does not support the property or method".

/ Rolf




Allen Browne said:
To debug this, open the Immediate Window (press Ctrl+G), and enter the
reference gradually, until you get it. For example:
? Forms!Form1.Name
That should return "Form1".

Then try:
? Forms!Form1!Sub1.Name
That should return Sub1. If it does not, check the Name property of the
subform control. It may be different from the name of the form loaded
into
the control (i.e. its SourceObject).

Once that's right, try:
? Forms.[Form1].[Sub1].[Form].[ProductID]
To see if you get the value of the ProductID, and so on.

--
Allen Browne - Microsoft MVP. Perth, Western Australia.

Reply to group, rather than allenbrowne at mvps dot org.

Something went wrong here. I did get a message that says, when I translate
to english, something like: "The object does not support the property
or
method". This happens independent of if the code is placed in the
forms
After_update or in a click event for a new button.

Your 3 first mentioned assumes are right. To the last one, the cursor
stands
on the row for a new record in the datasheet.
The same happens if the cursor is placed on an old record (even if that
was
not the intention).

/ Rolf



"Allen Browne" <[email protected]> skrev i meddelandet
In the AfterUpdate event proecdure of the ProductID in the 2nd form,
include
this line of code:
Forms.[Form1].[Sub1].[Form].[ProductID] = Me.[ProductID]

That assumes:
- The other form is called "Form1".
- Its subform is named "Sub1".
- The other form is still open.
- The other form has the correct record selected in the subform.


I have an order form with a datasheet-subform, where the order
specification
is made. The products are selected in a combo box. Now there are too
many
products to choose from, so I would like to let the user choose
products
a
little easier.

In another form, showing products and suppliers, I can let him first
choose
the supplier and then from there, choose the right product. But I
cannot
figure out how to take this product-ID and put it into the already open
datasheet-subform as a new record.

Can anyone help?
/ Rolf
 
A

Allen Browne

So is the text box called ProdID?
Does this work:
? Forms.[Form1].[Sub1].[Form].[ProdID]

You need to follow through until you understand what the names are, and so
how to refer to them in your code.

--
Allen Browne - Microsoft MVP. Perth, Western Australia.

Reply to group, rather than allenbrowne at mvps dot org.

Rolf Rosenquist said:
No, there is no space inside.
The ?TypeName.... delivers the same error as before.

In the Product form I have a button to bring the ProdID to the datasheet
in
the subform of another main form. The click event of this button has the
following row

Forms.[Order].[OrderSpec].[Form].[ProdID] = Me.[ProdID]

With help of a stop command just before, I can see that after this row,
the
cursor goes right down to the error handling and gives the message. When I
place the cursor above Me.[ProdID] I see the real value of 112 or whatever
is right for that product.

/ Rolf



Allen Browne said:
Okay, so the ProductID is the problem.

Is there a space in the name, e.g.:
? Forms.[Form1].[Sub1].[Form].[Product ID]

Is there some other kind of object with this name?
? TypeName(Forms.[Form1].[Sub1].[Form].[ProductID])

That's the process to debug what's going on.

--
Allen Browne - Microsoft MVP. Perth, Western Australia.

Reply to group, rather than allenbrowne at mvps dot org.

Rolf Rosenquist said:
The names of the forms come out as they should, but when I come to
ProductID, I get the same message as before. I also tried another
fieldname,
the registered bar code that also is unique, but got the same result: "The
object does not support the property or method".

/ Rolf




"Allen Browne" <[email protected]> skrev i meddelandet
To debug this, open the Immediate Window (press Ctrl+G), and enter the
reference gradually, until you get it. For example:
? Forms!Form1.Name
That should return "Form1".

Then try:
? Forms!Form1!Sub1.Name
That should return Sub1. If it does not, check the Name property of
the
subform control. It may be different from the name of the form loaded
into
the control (i.e. its SourceObject).

Once that's right, try:
? Forms.[Form1].[Sub1].[Form].[ProductID]
To see if you get the value of the ProductID, and so on.

--
Allen Browne - Microsoft MVP. Perth, Western Australia.

Reply to group, rather than allenbrowne at mvps dot org.

Something went wrong here. I did get a message that says, when I
translate
to english, something like: "The object does not support the
property
or
method". This happens independent of if the code is placed in the
forms
After_update or in a click event for a new button.

Your 3 first mentioned assumes are right. To the last one, the
cursor
stands
on the row for a new record in the datasheet.
The same happens if the cursor is placed on an old record (even if that
was
not the intention).

/ Rolf



"Allen Browne" <[email protected]> skrev i meddelandet
In the AfterUpdate event proecdure of the ProductID in the 2nd
form,
include
this line of code:
Forms.[Form1].[Sub1].[Form].[ProductID] = Me.[ProductID]

That assumes:
- The other form is called "Form1".
- Its subform is named "Sub1".
- The other form is still open.
- The other form has the correct record selected in the subform.


I have an order form with a datasheet-subform, where the order
specification
is made. The products are selected in a combo box. Now there are too
many
products to choose from, so I would like to let the user choose
products
a
little easier.

In another form, showing products and suppliers, I can let him first
choose
the supplier and then from there, choose the right product. But I
cannot
figure out how to take this product-ID and put it into the
already
open
datasheet-subform as a new record.

Can anyone help?
/ Rolf
 
R

Rolf Rosenquist

No, still same error.
I really don't think it is a wrong name. I have double and triple checked
the names.

The message says it does not support the property or method. What that now
means?
Is there some tricks to refer to the sub form when it it shown as a
datasheet?

Normally I take a reference field from one form to another without problems.

/ Rolf


Allen Browne said:
So is the text box called ProdID?
Does this work:
? Forms.[Form1].[Sub1].[Form].[ProdID]

You need to follow through until you understand what the names are, and so
how to refer to them in your code.

--
Allen Browne - Microsoft MVP. Perth, Western Australia.

Reply to group, rather than allenbrowne at mvps dot org.

Rolf Rosenquist said:
No, there is no space inside.
The ?TypeName.... delivers the same error as before.

In the Product form I have a button to bring the ProdID to the datasheet
in
the subform of another main form. The click event of this button has the
following row

Forms.[Order].[OrderSpec].[Form].[ProdID] = Me.[ProdID]

With help of a stop command just before, I can see that after this row,
the
cursor goes right down to the error handling and gives the message. When I
place the cursor above Me.[ProdID] I see the real value of 112 or whatever
is right for that product.

/ Rolf



Allen Browne said:
Okay, so the ProductID is the problem.

Is there a space in the name, e.g.:
? Forms.[Form1].[Sub1].[Form].[Product ID]

Is there some other kind of object with this name?
? TypeName(Forms.[Form1].[Sub1].[Form].[ProductID])

That's the process to debug what's going on.

--
Allen Browne - Microsoft MVP. Perth, Western Australia.

Reply to group, rather than allenbrowne at mvps dot org.

The names of the forms come out as they should, but when I come to
ProductID, I get the same message as before. I also tried another
fieldname,
the registered bar code that also is unique, but got the same result: "The
object does not support the property or method".

/ Rolf




"Allen Browne" <[email protected]> skrev i meddelandet
To debug this, open the Immediate Window (press Ctrl+G), and enter the
reference gradually, until you get it. For example:
? Forms!Form1.Name
That should return "Form1".

Then try:
? Forms!Form1!Sub1.Name
That should return Sub1. If it does not, check the Name property of
the
subform control. It may be different from the name of the form loaded
into
the control (i.e. its SourceObject).

Once that's right, try:
? Forms.[Form1].[Sub1].[Form].[ProductID]
To see if you get the value of the ProductID, and so on.

--
Allen Browne - Microsoft MVP. Perth, Western Australia.

Reply to group, rather than allenbrowne at mvps dot org.

Something went wrong here. I did get a message that says, when I
translate
to english, something like: "The object does not support the
property
or
method". This happens independent of if the code is placed in the
forms
After_update or in a click event for a new button.

Your 3 first mentioned assumes are right. To the last one, the
cursor
stands
on the row for a new record in the datasheet.
The same happens if the cursor is placed on an old record (even if that
was
not the intention).

/ Rolf



"Allen Browne" <[email protected]> skrev i meddelandet
In the AfterUpdate event proecdure of the ProductID in the 2nd
form,
include
this line of code:
Forms.[Form1].[Sub1].[Form].[ProductID] = Me.[ProductID]

That assumes:
- The other form is called "Form1".
- Its subform is named "Sub1".
- The other form is still open.
- The other form has the correct record selected in the subform.


I have an order form with a datasheet-subform, where the order
specification
is made. The products are selected in a combo box. Now there
are
too
many
products to choose from, so I would like to let the user choose
products
a
little easier.

In another form, showing products and suppliers, I can let him first
choose
the supplier and then from there, choose the right product. But I
cannot
figure out how to take this product-ID and put it into the
already
open
datasheet-subform as a new record.

Can anyone help?
/ Rolf
 
R

Rolf Rosenquist

Now it works. I changed the dots to excamation marks and took the last Form
away - and it just worked!

It lookes like this:
Forms![Order]![OrderSpec]![ProdID] = Me.[ProdID]

Thank you for helping out and putting me in the right direction.
/ Rolf



Allen Browne said:
So is the text box called ProdID?
Does this work:
? Forms.[Form1].[Sub1].[Form].[ProdID]

You need to follow through until you understand what the names are, and so
how to refer to them in your code.

--
Allen Browne - Microsoft MVP. Perth, Western Australia.

Reply to group, rather than allenbrowne at mvps dot org.

Rolf Rosenquist said:
No, there is no space inside.
The ?TypeName.... delivers the same error as before.

In the Product form I have a button to bring the ProdID to the datasheet
in
the subform of another main form. The click event of this button has the
following row

Forms.[Order].[OrderSpec].[Form].[ProdID] = Me.[ProdID]

With help of a stop command just before, I can see that after this row,
the
cursor goes right down to the error handling and gives the message. When I
place the cursor above Me.[ProdID] I see the real value of 112 or whatever
is right for that product.

/ Rolf



Allen Browne said:
Okay, so the ProductID is the problem.

Is there a space in the name, e.g.:
? Forms.[Form1].[Sub1].[Form].[Product ID]

Is there some other kind of object with this name?
? TypeName(Forms.[Form1].[Sub1].[Form].[ProductID])

That's the process to debug what's going on.

--
Allen Browne - Microsoft MVP. Perth, Western Australia.

Reply to group, rather than allenbrowne at mvps dot org.

The names of the forms come out as they should, but when I come to
ProductID, I get the same message as before. I also tried another
fieldname,
the registered bar code that also is unique, but got the same result: "The
object does not support the property or method".

/ Rolf




"Allen Browne" <[email protected]> skrev i meddelandet
To debug this, open the Immediate Window (press Ctrl+G), and enter the
reference gradually, until you get it. For example:
? Forms!Form1.Name
That should return "Form1".

Then try:
? Forms!Form1!Sub1.Name
That should return Sub1. If it does not, check the Name property of
the
subform control. It may be different from the name of the form loaded
into
the control (i.e. its SourceObject).

Once that's right, try:
? Forms.[Form1].[Sub1].[Form].[ProductID]
To see if you get the value of the ProductID, and so on.

--
Allen Browne - Microsoft MVP. Perth, Western Australia.

Reply to group, rather than allenbrowne at mvps dot org.

Something went wrong here. I did get a message that says, when I
translate
to english, something like: "The object does not support the
property
or
method". This happens independent of if the code is placed in the
forms
After_update or in a click event for a new button.

Your 3 first mentioned assumes are right. To the last one, the
cursor
stands
on the row for a new record in the datasheet.
The same happens if the cursor is placed on an old record (even if that
was
not the intention).

/ Rolf



"Allen Browne" <[email protected]> skrev i meddelandet
In the AfterUpdate event proecdure of the ProductID in the 2nd
form,
include
this line of code:
Forms.[Form1].[Sub1].[Form].[ProductID] = Me.[ProductID]

That assumes:
- The other form is called "Form1".
- Its subform is named "Sub1".
- The other form is still open.
- The other form has the correct record selected in the subform.


I have an order form with a datasheet-subform, where the order
specification
is made. The products are selected in a combo box. Now there
are
too
many
products to choose from, so I would like to let the user choose
products
a
little easier.

In another form, showing products and suppliers, I can let him first
choose
the supplier and then from there, choose the right product. But I
cannot
figure out how to take this product-ID and put it into the
already
open
datasheet-subform as a new record.

Can anyone help?
/ Rolf
 
A

Allen Browne

Okay: that reference makes sense in its own right, but if that worked and
the other did not but the names are correct, then the project is partially
corrupt, probably caused by Name AutoCorrect.

Suggest you at least:
1. Uncheck the Name AutoCorrect boxes under:
Tools | Options | General

2. Compact the database:
Tools | Database Utilities | Compact.

For a list of some of the problems caused by Name AutoCorrect, see:
http://members.iinet.net.au/~allenbrowne/bug-03.html
 
R

Rolf Rosenquist

Good. I have done these two last suggestions now.
Thanks again.
/ Rolf




Allen Browne said:
Okay: that reference makes sense in its own right, but if that worked and
the other did not but the names are correct, then the project is partially
corrupt, probably caused by Name AutoCorrect.

Suggest you at least:
1. Uncheck the Name AutoCorrect boxes under:
Tools | Options | General

2. Compact the database:
Tools | Database Utilities | Compact.

For a list of some of the problems caused by Name AutoCorrect, see:
http://members.iinet.net.au/~allenbrowne/bug-03.html

--
Allen Browne - Microsoft MVP. Perth, Western Australia.

Reply to group, rather than allenbrowne at mvps dot org.

Rolf Rosenquist said:
Now it works. I changed the dots to excamation marks and took the last
Form
away - and it just worked!

It lookes like this:
Forms![Order]![OrderSpec]![ProdID] = Me.[ProdID]

Thank you for helping out and putting me in the right direction.
/ Rolf
 

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