Error Message if no data

G

Guest

Hi all,

I have a form and a subform where the data from the form is automatically
entered into the subform by pressing a button with a code:
Me.SF_APV.Form.[ToFrom1] = Me.[ToFrom1]
(Which works all right.)

I want to make sure the button is pressed only after the data is entered
into the main form. So I want to make a warning window to appear if this
button is pressed while the field in the main form is empty.

I know nothing about programming and i looked for a similar questions in
this forum and found something like:

If IsNull(ToFrom1) Then
strMessage = strMessage & "No Name is Entered!" & vbCrLf
Else
Me.SF_APV.Form.[ToFrom1] = Me.[ToFrom1]
End If

I inserted this code into my button, but nothing happens, - i mean - no
warning appears and the field in the subform remains blank if it was blank on
the main form.

What am i doing wrong? Can somebody help me please?

Thank you.
Lana
 
G

Guest

Why aren't you using the parent and child properties to link the SubForm to
the MainForm?
=========================
For your question.
MyBe the Field is empty and not null, and add Me in front of (ToFrom1)

If IsNull(Me.[ToFrom1]) Or Trim(Me.[ToFrom1]) = "" Then
strMessage = strMessage & "No Name is Entered!" & vbCrLf
Else
Me.SF_APV.Form.[ToFrom1] = Me.[ToFrom1]
End If
 
T

tina

and what are you doing with "strMessage"? and with the vbCrLf? how about

If IsNull(Me.[ToFrom1]) Or Trim(Me.[ToFrom1]) = "" Then
MsgBox "No Name is Entered!"
Else
Me.SF_APV.Form.[ToFrom1] = Me.[ToFrom1]
End If

hth


Ofer said:
Why aren't you using the parent and child properties to link the SubForm to
the MainForm?
=========================
For your question.
MyBe the Field is empty and not null, and add Me in front of (ToFrom1)

If IsNull(Me.[ToFrom1]) Or Trim(Me.[ToFrom1]) = "" Then
strMessage = strMessage & "No Name is Entered!" & vbCrLf
Else
Me.SF_APV.Form.[ToFrom1] = Me.[ToFrom1]
End If

--
\\// Live Long and Prosper \\//


Lana said:
Hi all,

I have a form and a subform where the data from the form is automatically
entered into the subform by pressing a button with a code:
Me.SF_APV.Form.[ToFrom1] = Me.[ToFrom1]
(Which works all right.)

I want to make sure the button is pressed only after the data is entered
into the main form. So I want to make a warning window to appear if this
button is pressed while the field in the main form is empty.

I know nothing about programming and i looked for a similar questions in
this forum and found something like:

If IsNull(ToFrom1) Then
strMessage = strMessage & "No Name is Entered!" & vbCrLf
Else
Me.SF_APV.Form.[ToFrom1] = Me.[ToFrom1]
End If

I inserted this code into my button, but nothing happens, - i mean - no
warning appears and the field in the subform remains blank if it was blank on
the main form.

What am i doing wrong? Can somebody help me please?

Thank you.
Lana
 
G

Guest

Thank you so much Tina! It worked!
Lana


tina said:
and what are you doing with "strMessage"? and with the vbCrLf? how about

If IsNull(Me.[ToFrom1]) Or Trim(Me.[ToFrom1]) = "" Then
MsgBox "No Name is Entered!"
Else
Me.SF_APV.Form.[ToFrom1] = Me.[ToFrom1]
End If

hth


Ofer said:
Why aren't you using the parent and child properties to link the SubForm to
the MainForm?
=========================
For your question.
MyBe the Field is empty and not null, and add Me in front of (ToFrom1)

If IsNull(Me.[ToFrom1]) Or Trim(Me.[ToFrom1]) = "" Then
strMessage = strMessage & "No Name is Entered!" & vbCrLf
Else
Me.SF_APV.Form.[ToFrom1] = Me.[ToFrom1]
End If

--
\\// Live Long and Prosper \\//


Lana said:
Hi all,

I have a form and a subform where the data from the form is automatically
entered into the subform by pressing a button with a code:
Me.SF_APV.Form.[ToFrom1] = Me.[ToFrom1]
(Which works all right.)

I want to make sure the button is pressed only after the data is entered
into the main form. So I want to make a warning window to appear if this
button is pressed while the field in the main form is empty.

I know nothing about programming and i looked for a similar questions in
this forum and found something like:

If IsNull(ToFrom1) Then
strMessage = strMessage & "No Name is Entered!" & vbCrLf
Else
Me.SF_APV.Form.[ToFrom1] = Me.[ToFrom1]
End If

I inserted this code into my button, but nothing happens, - i mean - no
warning appears and the field in the subform remains blank if it was blank on
the main form.

What am i doing wrong? Can somebody help me please?

Thank you.
Lana
 
T

tina

you're welcome :)


Lana said:
Thank you so much Tina! It worked!
Lana


tina said:
and what are you doing with "strMessage"? and with the vbCrLf? how about

If IsNull(Me.[ToFrom1]) Or Trim(Me.[ToFrom1]) = "" Then
MsgBox "No Name is Entered!"
Else
Me.SF_APV.Form.[ToFrom1] = Me.[ToFrom1]
End If

hth


Ofer said:
Why aren't you using the parent and child properties to link the
SubForm
to
the MainForm?
=========================
For your question.
MyBe the Field is empty and not null, and add Me in front of (ToFrom1)

If IsNull(Me.[ToFrom1]) Or Trim(Me.[ToFrom1]) = "" Then
strMessage = strMessage & "No Name is Entered!" & vbCrLf
Else
Me.SF_APV.Form.[ToFrom1] = Me.[ToFrom1]
End If

--
\\// Live Long and Prosper \\//


:

Hi all,

I have a form and a subform where the data from the form is automatically
entered into the subform by pressing a button with a code:
Me.SF_APV.Form.[ToFrom1] = Me.[ToFrom1]
(Which works all right.)

I want to make sure the button is pressed only after the data is entered
into the main form. So I want to make a warning window to appear if this
button is pressed while the field in the main form is empty.

I know nothing about programming and i looked for a similar
questions
in
this forum and found something like:

If IsNull(ToFrom1) Then
strMessage = strMessage & "No Name is Entered!" & vbCrLf
Else
Me.SF_APV.Form.[ToFrom1] = Me.[ToFrom1]
End If

I inserted this code into my button, but nothing happens, - i mean - no
warning appears and the field in the subform remains blank if it was blank on
the main form.

What am i doing wrong? Can somebody help me please?

Thank you.
Lana
 

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