Prefilled Form

  • Thread starter Thread starter Microsoft
  • Start date Start date
M

Microsoft

Access 2007

Is it possible to open a form that automatically creates 5 records in a
table?
if yes how

thanks
A
 
I dont want to do it but the users do and ones the MD :-(

Each project can have a value against all or none of the records that I
create.

I want to keep my table structure as:
ProjectNo Code Value

NOT
ProjectNo Code1 Code1Value Code2 Code2Value code3 Code3Value etc

If I use continuous forms it will mean, I think, having the table structure
that I don't want therefore if I create the records for each project and
then display them on the form everyone will be happy except that there will
be a lot of empty records.
 
Hi (what is your name?)

although I disagree with this .... here is code:

'~~~~~~~~~~~~
dim strSQL as string _
, i as integer

' if me.ProjectNo is not filled out, do nothing
if IsNull(me.ProjectNo) then exit sub

for i = 1 to 5
strSQL = "INSERT INTO [Tablename] " _
& " (ProjectNo) " _
& " SELECT " & me.ProjectNo
CurrentDb.Execute strSQL
next i

me.subform_controlname.requery
'~~~~~~~~~~~~~~~~

WHERE
Tablename is the name of the table
ProjectNo is the field in Tablename for ProjectNo
me.ProjectNo is a reference to a control on the form that contains the
ProjectNo
ProjectNo is assumed to be numeric -- it is it text, you will need to
substitute:

& " SELECT '" & me.ProjectNo & "'"

~~~
do not use VALUE as a fieldname, it is a reserved word

Problem names and reserved words in Access, by Allen Browne
http://www.allenbrowne.com/AppIssueBadWord.html


Warm Regards,
Crystal

remote programming and training

Access Basics
8-part free tutorial that covers essentials in Access
http://www.AccessMVP.com/strive4peace

*
(: have an awesome day :)
*
 
thanks
strive4peace said:
Hi (what is your name?)

although I disagree with this .... here is code:

'~~~~~~~~~~~~
dim strSQL as string _
, i as integer

' if me.ProjectNo is not filled out, do nothing
if IsNull(me.ProjectNo) then exit sub

for i = 1 to 5
strSQL = "INSERT INTO [Tablename] " _
& " (ProjectNo) " _
& " SELECT " & me.ProjectNo
CurrentDb.Execute strSQL
next i

me.subform_controlname.requery
'~~~~~~~~~~~~~~~~

WHERE
Tablename is the name of the table
ProjectNo is the field in Tablename for ProjectNo
me.ProjectNo is a reference to a control on the form that contains the
ProjectNo
ProjectNo is assumed to be numeric -- it is it text, you will need to
substitute:

& " SELECT '" & me.ProjectNo & "'"

~~~
do not use VALUE as a fieldname, it is a reserved word

Problem names and reserved words in Access, by Allen Browne
http://www.allenbrowne.com/AppIssueBadWord.html


Warm Regards,
Crystal

remote programming and training

Access Basics
8-part free tutorial that covers essentials in Access
http://www.AccessMVP.com/strive4peace

*
(: have an awesome day :)
*



I dont want to do it but the users do and ones the MD :-(

Each project can have a value against all or none of the records that I
create.

I want to keep my table structure as:
ProjectNo Code Value

NOT
ProjectNo Code1 Code1Value Code2 Code2Value code3 Code3Value etc

If I use continuous forms it will mean, I think, having the table
structure that I don't want therefore if I create the records for each
project and then display them on the form everyone will be happy except
that there will be a lot of empty records.
 
Microsoft said:
I dont want to do it but the users do and ones the MD :-(

Each project can have a value against all or none of the records that I
create.

I want to keep my table structure as:
ProjectNo Code Value

NOT
ProjectNo Code1 Code1Value Code2 Code2Value code3 Code3Value etc

If I use continuous forms it will mean, I think, having the table structure
that I don't want therefore if I create the records for each project and
then display them on the form everyone will be happy except that there will
be a lot of empty records.
 
you're welcome

Warm Regards,
Crystal

remote programming and training

Access Basics
8-part free tutorial that covers essentials in Access
http://www.AccessMVP.com/strive4peace

*
(: have an awesome day :)
*



thanks
strive4peace said:
Hi (what is your name?)

although I disagree with this .... here is code:

'~~~~~~~~~~~~
dim strSQL as string _
, i as integer

' if me.ProjectNo is not filled out, do nothing
if IsNull(me.ProjectNo) then exit sub

for i = 1 to 5
strSQL = "INSERT INTO [Tablename] " _
& " (ProjectNo) " _
& " SELECT " & me.ProjectNo
CurrentDb.Execute strSQL
next i

me.subform_controlname.requery
'~~~~~~~~~~~~~~~~

WHERE
Tablename is the name of the table
ProjectNo is the field in Tablename for ProjectNo
me.ProjectNo is a reference to a control on the form that contains the
ProjectNo
ProjectNo is assumed to be numeric -- it is it text, you will need to
substitute:

& " SELECT '" & me.ProjectNo & "'"

~~~
do not use VALUE as a fieldname, it is a reserved word

Problem names and reserved words in Access, by Allen Browne
http://www.allenbrowne.com/AppIssueBadWord.html


Warm Regards,
Crystal

remote programming and training

Access Basics
8-part free tutorial that covers essentials in Access
http://www.AccessMVP.com/strive4peace

*
(: have an awesome day :)
*



I dont want to do it but the users do and ones the MD :-(

Each project can have a value against all or none of the records that I
create.

I want to keep my table structure as:
ProjectNo Code Value

NOT
ProjectNo Code1 Code1Value Code2 Code2Value code3 Code3Value etc

If I use continuous forms it will mean, I think, having the table
structure that I don't want therefore if I create the records for each
project and then display them on the form everyone will be happy except
that there will be a lot of empty records.


yes, but why would you want to do that?

Warm Regards,
Crystal

remote programming and training

Access Basics
8-part free tutorial that covers essentials in Access
http://www.AccessMVP.com/strive4peace

*
(: have an awesome day :)
*




Microsoft wrote:
Access 2007

Is it possible to open a form that automatically creates 5 records in a
table?
if yes how

thanks
A
 
Back
Top