Subform row selected

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

Guest

How would you recognize when a row in a subform has been selected.
I have a form with a subform with a button that moves the selected item to
an other table using a SQL. I would like the button to be disenabled till a
row has been selected. Isn’t their a row selected propertied or is it a
method? I need help with my if statement. Don’t I need to qualify my subform?

Dim selected As Boolean
selected = False
if (frmNameSub row selected = true) then selected =true
else selected = false
cmdRemoveItem.Enabled = selected

Thank you,
Gus Chuchanis
 
Access tables do not have "rows", they have records. forms and subforms
display those records - not rows, even though Datasheet view looks similar
to an Excel spreadsheet which does have rows.

a form (or a subform) has a CurrentRecord property. in Datasheet view,
whatever record has the focus (I-beam in a control) is the CurrentRecord. in
VBA, when you refer to the value of a specific control or field in the form,
the value returned is from the CurrentRecord. for instance, if you're in the
second record, and refer to the value of FieldA, you'll get the value of
FieldA *in the second record*, not from some other record in the form.

to delete a record from the underlying table, just move to the record in the
subform and run a Delete query from the command button, as

CurrentDb.Execute "Delete * FROM TableName " _
& "WHERE PrimaryKeyField = " _
& Me!PrimaryKeyField, dbFailOnError

substitute the correct name of the table's primary key field, of course.

hth
 
I’m not trying to DELETE the item I’m just moving it to another table with my
cmdRemoveItem command and all that works just fine. I just would like to
disable the button till a row in the subform has been selected.
 
Back
Top