requery & autofill questions

  • Thread starter Slez via AccessMonster.com
  • Start date
S

Slez via AccessMonster.com

I have a combo box on a main form called cboProjectName. It's source is a
table which contains the fields ProjectID and ProjectName (primary keys).
The main form stays open as it is sort of the databases "home page". Next to
cboProjectName is a command button which runs a macro: macFormAddNewProject.
It opens frmAddNewProject, goes to the new record, and resizes the form. On
this form is a control for the field ProjectName. When users need to add a
project into the database, they click the command button and type in the name
of a new project, then click "Accept" to do just that, or "Cancel", which
Undoes the new record. With all that said, I have 2 questions about things
I'd like frmAddNewProject to do.

1) After "Accept" is clicked, the record is added to the table, and
frmAddNewProject closes. On the main form, which as I mentioned remains open,
cboProjectName does not yet show that new record unless you close the main
form and re-open it. Is there a way to requery or refresh the records in
cboProjectName?

2) Because the field ProjectID exists, in theory, users could enter the same
exact name in the ProjectName field in frmAddNewProject and mistakenly create
a duplicate project. Is there a way to have this field autofill or something
that would alert users that they're in the process of entering a repeat or
similar name as a new record?

Thanks in advance for any feedback!
 
M

Maver911

Slez said:
I have a combo box on a main form called cboProjectName. It's source is a
table which contains the fields ProjectID and ProjectName (primary keys).
The main form stays open as it is sort of the databases "home page". Next to
cboProjectName is a command button which runs a macro: macFormAddNewProject.
It opens frmAddNewProject, goes to the new record, and resizes the form. On
this form is a control for the field ProjectName. When users need to add a
project into the database, they click the command button and type in the name
of a new project, then click "Accept" to do just that, or "Cancel", which
Undoes the new record. With all that said, I have 2 questions about things
I'd like frmAddNewProject to do.

1) After "Accept" is clicked, the record is added to the table, and
frmAddNewProject closes. On the main form, which as I mentioned remains open,
cboProjectName does not yet show that new record unless you close the main
form and re-open it. Is there a way to requery or refresh the records in
cboProjectName?

2) Because the field ProjectID exists, in theory, users could enter the same
exact name in the ProjectName field in frmAddNewProject and mistakenly create
a duplicate project. Is there a way to have this field autofill or something
that would alert users that they're in the process of entering a repeat or
similar name as a new record?

Thanks in advance for any feedback!

1) just a quick idea that i thought about for you is that when the form
gets focus you could requery the combobox like: cboProjectName.requery

2) How are you saving the record? Are you using VBA or are you using a
different method?
 
S

Slez via AccessMonster.com

1) That method worked perfect! Thank you!

2) Once the "Accept" button is clicked, it closes the form with the new
record, so I would say I'm not using VBA...at least not intentionally. The
key to this is that Access doesn't view it as an duplicate because of
ProjectID being a primary key also, so I'm sort of looking for an alternative
method.

Slez
I have a combo box on a main form called cboProjectName. It's source is a
table which contains the fields ProjectID and ProjectName (primary keys).
[quoted text clipped - 24 lines]
Message posted via AccessMonster.com

1) just a quick idea that i thought about for you is that when the form
gets focus you could requery the combobox like: cboProjectName.requery

2) How are you saving the record? Are you using VBA or are you using a
different method?
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top