Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Autonumber- primary key 1

Status
Not open for further replies.

Form1

Programmer
Apr 27, 2005
12
I have form A which has field "FID".

I want set the value FID=Me.OpenArgs when something changes in my form

I tried setting the value in form close but it didn't work.

Where should I place my code?

None of the field is mandatory except primary key which is automatically generated. I have many controls so I can not place code in afterUpdate event of every control.

I have one more problem I'm doing record copy using built in Duplicate Command. My table has many fields so when I Copy Access pops up some message(You copied large amount of data on to clipboard) how to disable this message.

How to reset the autonumber to start from zero in production database.

thanks for the help
 
How are ya Form1 . . . . .
Form1 said:
[blue]I want set the value FID=Me.OpenArgs [purple]when something changes in my form[/purple][/blue]
Try the forms [purple]OnDirty Event[/purple]. [blue]This event triggers whenever a new or existing record is edited.[/blue] It can't tell you if the user reverts back to the origional data, either by data entry or hitting ESC key, but you'll at least know an attempt to edit was made.
Form1 said:
[blue]I'm doing record copy using built in [purple]Duplicate Command[/purple][/blue]
This command is not ringing a bell. Whats the real name of the command?

In any case, if your running the command in VBA, try this:
Code:
[blue]   DoCmd.SetWarnings False
   [green]'your code here[/green]
   DoCmd.SetWarnings True[/blue]

Calvin.gif
See Ya! . . . . . .
 
Thanks for the response.

I want to set the value only when the user adds new record.
I don't want this event to trigger when user copies or edit the record. If I place my code in OnDirty event it will trigger for everything.

Is there any other way to do it?

If you check Northwind sample database when user clicks Add product in Suppliers form Supplier ID is automatically updated in Product Form. My case is somewhat similar to that.

What I meant by Built in COpy command is when you paste a command button on the scren you can associate it some built in actions say if you select record operations then there is Duplicate Record Command.

I'm getting the warning message when I try to close the form. If I place DoCmd.SetWarnings False in Form close it works.

Where should I set it back to true. I don't want to suppress other warnings.

Thanks once again.

 
OK Form1 . . . . .

You have two options:
[ol][li]Set the [blue]Default Value[/blue] of FID when the form is opened. New Records will always have the value there, ready to go. For this method, in the forms [blue]OnLoad[/blue] event you would have:
Code:
[blue]Me!FID.DefaultValue = Me.OpenArgs[/blue]
[/li]
[li]Set the [blue]Default Value[/blue] when the user moves to a new record. For this method, in the forms [blue]OnCurrent[/blue] event you would have:
Code:
[blue]   If Me.NewRecord Then
      Me!FID.DefaultValue = Me.OpenArgs
   End If[/blue]
[/li][/ol]
The [blue]Default Value[/blue] is a better choice here, as it does not trigger [blue]Edit Mode[/blue]. Users can navigate anywhere else (off the new record) without a record being saved with just an FID value.

Special Note: The [blue]OpenArgs[/blue] parameter only excepts a string. Therefore if you want to pass numeric, [blue]two conversions are required.[/blue]
Code:
[blue][purple]Conversion to text in DoCmd.OpenForm:[/purple]
   DoCmd.OpenForm "FormName", , , , , , [purple][b]Str[/b][/purple](NumericExpression)

[purple]Then back to numeric in the opened form:[/purple]
Me!FID.DefaultValue = [purple][b]Val[/b][/purple](Me.OpenArgs)[/blue]


Calvin.gif
See Ya! . . . . . .
 
Thanks a lot. This is exactly what I wanted.

I have one more problem in Reports.
I hace created block tabular report. One of my text box
has many line.

The tex box displays only part of the information.

Is there way to set auto fit the contents?
Is ther any other control for Tabular display.

 
Form1 . . . . .

Have a look at [blue]Can Shrink/Grow properties[/blue] . . .

Calvin.gif
See Ya! . . . . . .
 
I tried Can grow but only that text box will be expanded
and I want all the text box in that row to be of same size.

Is there way to display the report in Excel format?
 
Form1 . . . . .

Your right. Post this problem in the Reports Forum.

Calvin.gif
See Ya! . . . . . .
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top