Question : MS Access Macro Auto Select Both Combo Box and Text Box at Same time in Same form

Hi,

We have this database and sometimes we will need to add an information repeatedly on 2 fields which is a drop down field linked to a table and a text field. What we want is for those field to be automatically updated unless we choose a different one from the selection More like this sentence - "If the field is empty then copy the information from the previous entry"

Here is what I found to autoselect a combo box (thanks to SimonAdept) but we now need something that can auto update both a text field and a combo box in one form.

private sub combo1_afterupdate()
  me.combo1.tag = me.combo1
end sub

Then in the on_current event for the form:

private sub form_current()
  if me.newrecord then
    me.combo1 = me.combo1.tag
  end if
end sub

Answer : MS Access Macro Auto Select Both Combo Box and Text Box at Same time in Same form

For the text box, you also need to set its tag value.

There can only be ONE form_current event for the form, so put both combobox and textbox updates into the one event handler as shown below.

private sub combo1_afterupdate()
  me.combo1.tag = me.combo1
end sub

private sub Text1_afterupdate()
  me.Text1.tag = me.Text1
end sub
----------------------------------------------------------
private sub form_current()
  if me.newrecord then
    me.combo1 = me.combo1.tag
    me.Text1 = me.Text1.tag
  end if
end sub
Random Solutions  
 
programming4us programming4us