Create a form specific to field on the form

  • Thread starter Thread starter Ravi
  • Start date Start date
R

Ravi

I have to create a note field, which should be tied to the one record on the
form. In other words, ever record will have commend button and clicking on it
should open a form specific to that record.
Your help is much appreciated.
 
You should be able to have the form open by using something like this:

DoCmd.OpenForm "YourFormNameHere", , , "[YourKeyFieldNameHere]= " &
Me!YourKeyFieldNameHere
 
You should be able to have the form open by using something like this:

DoCmd.OpenForm "YourFormNameHere", , , "[YourKeyFieldNameHere]= " &
Me!YourKeyFieldNameHere
 
You have a choice of either including a memo field in the same table to which
the form is bound, or in a separate table related one-to-one to the current
table. The latter has the advantage that, in the event of the separate table
containing the memo field becoming corrupted the existing table is unaffected.

If you do use a separate table then give it a foreign key column which
references the primary key of the existing table, but in the new table also
designate this column as the primary key. Note that the column in the new
table must not be an autonumber. When you create a relationship between the
tables it will then be a one-to-one relationship.

If you put the memo field in the existing table then create a new form bound
to the existing table, but include only a text box control bound to the memo
field in the new form. If you out the memo field in a separate table then do
the same, but bind the form to the new table. In either case set the new
form's AllowAdditions and AllowDeletions properties to False (No).

Whichever way you do it open the new form from a button on your current form
with code along these lines:

Const conFORM = "frmNotes"
Dim strCriteria As String

strCriteria = "[MyID] = " & Me.[MyID]

' ensure current record is saved
Me.Dirty = False
' open Notes form in dialogue mode
DoCmd.OpenForm conFORM, _
WhereCondition:=strCriteria, _
WindowMode:=acDialog

where MyID is the primary key of the existing form's table and of the
separate Notes table if you've created one, and frmNotes is the name of the
new form. I've assumed that MyID is a number data type. If it’s a text data
type amend the code to:

strCriteria = "[MyID] = """ & Me.[MyID] & """"

Ken Sheridan
Stafford, England
 
Back
Top