Bound form New Record

wrightyrx7

Registered User.
Local time
Today, 04:07
Joined
Sep 4, 2014
Messages
104
HI all,

Dont know how to explain this one, but will try my best.

I have two tables:-
  • Vacancies
  • Applicants

Three forms:-
  • Main - contains a subform (data source = Vacancies table)
  • Vacancies - opens vacany record when ID in subform clicked
  • Applicants - data source is a Query of both above tables joined

When I go into the a vacancy i want a button to add new applicant.

However when i use:-
Code:
DoCmd.OpenForm "Applicants", , , "Vacancy_ID=" & Me![Vacancy_ID]

It opens the 'Applicants' form with an already existing Applicant details.

I want it to pull through the Vacancy details but add a new applicant details.

How should i go about doing this?

Thanks in advance
Chris
 
You probably want to open the form in Add mode.
I would probably check to see if the form is already open.

Code:
On Error Resume Next
    Dim f As Form
    Set f = Forms!Applicants
    If Err.Number Then
        DoCmd.OpenForm "Applicants", , , , acFormAdd
    Else
        f.SetFocus
        DoCmd.GoToRecord acDataForm, "Applicants", acNewRec
    End If
    Forms!Applicants!Vacancy_ID = Vacancy_ID
 
You probably want to open the form in Add mode.
I would probably check to see if the form is already open.

Code:
On Error Resume Next
    Dim f As Form
    Set f = Forms!Applicants
    If Err.Number Then
        DoCmd.OpenForm "Applicants", , , , acFormAdd
    Else
        f.SetFocus
        DoCmd.GoToRecord acDataForm, "Applicants", acNewRec
    End If
    Forms!Applicants!Vacancy_ID = Vacancy_ID

STATIC!!! Thank you so much.

Work just as i wanted :)
 

Users who are viewing this thread

Back
Top Bottom