automatically filling in fields in form

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

I'm a new Access developer working on my first application. I have a form
with a command button on it, and when I click on the button, it opens a
second form , setting a WHERE clause and passing OpenArgs to it. This part
is working. The second form displays multiple records, and after it opens, I
want to add a new record to the form, scroll to it, and automatically fill
one of the fields in the new record, based on information I passed to the
form using OpenArgs.

I'm sure this is simple, but I can't seem to find the right help pages to
show me how to do this.

Thanks is advance,

Ron
 
Try this
On the OnLoad event of the second form enter the code

Me.FieldName.DefaultValue = Me.OpenArgs
 
This is a method I use in applications I develope:

I have a standard module declaring some public variables that I can use when
swapping between forms without getting involved in complicated code. I have
one (Or more) variable for each data type

eg. pubStoreLong As Long, pubStoreString As String, pubStoreDate as Date,
pubStoreLoot as Currency.

It is then simple to store whatever bit of data in one of these variables,
open the new form and put the variable's value into the appropriate control.

Purists may say that public variables should not be used as they take up
memory but with the the amount of memory available to modern machines I think
the simplicity of coding AND DEBUGGING more than offsets the memory cost.
 
Back
Top