Three little doubts... Variable, Field value and Deletion. (1 Viewer)

brunces

Registered User.
Local time
Today, 08:03
Joined
Sep 12, 2004
Messages
45
Friends,

Hi, everyone.

Please, anybody can help me with these?...

-----

1) How to show the value of a variable inside a TextBox, in a form or report? I know how to show it in a MsgBox, but I want it to be shown in a TextBox, merged with some other texts of mine.

Example:

"It's been " & varNumberOfDays & " days, since I left my hometown."

-----

2) How to show the value of a field (which has no relation to the current form or report) inside a TextBox?

Example:

A form related to "tblClients" and not related to "tblSearchProduct".

"Client wants to buy a new " & [tblSearchProduct].[ProductName] & " in cash."

-----

3) How to delete the CurrentRecord after checking a criteria (updating of a field)?

Example:

Form has 2 fields. If field 2 is updated and field 1 is still Null, this record is deleted.

On AfterUpdate Event for the field 2, a code has to check if field 1 is already filled. If so, I do what I want. If not, a MsgBox appears ("This record can't be saved!") and then this current record is automatically deleted.

-----

Hope someone can help me.

Thank you very much for your attention, guys. :)

Hugz.

Bruno
 

panaseam

New member
Local time
Today, 12:03
Joined
Oct 13, 2004
Messages
7
Hi brunces,

1) One way would be to make the variable you are interested in dispaying
a Public variable in a Module then creating a Public Function that returns the value of the variable.
e.g.
Public varNumberOfDays As Integer

Public Function getMyVarToDisplay() As Integer
getMyVarToDisplay = varNumberOfDays
End Function

Then set the ControlSource property of your TextBox to
="It's been " & getMyVarToDisplay() & " days, since I left my hometown."

2) Set the ControlSource property to
="Client wants to buy a new " & DLookup("[ProductName]","[tblSearchProduct]") & " in cash."

3) I need to think about this one.

Hope 1 & 2 are some help
 

brunces

Registered User.
Local time
Today, 08:03
Joined
Sep 12, 2004
Messages
45
Thanks a lot.

panaseam,

Hi, buddy.

Yes, you've already helped me a lot. :)

About doubt #3... I've created a a code which is working fine, but it deletes the "last record". But, it can't be so. Sometimes it works, sometimes it doesn't (then it deletes something it couldn't delete).

I'm still thinkin as well.

Thank you, friend. :)

Hugz.

Bruno
 

panaseam

New member
Local time
Today, 12:03
Joined
Oct 13, 2004
Messages
7
Hi again,

You could delete the current record by doing this:
Code:
Me.RecordsetClone.Bookmark = Me.Bookmark
Me.RecordsetClone.Delete
But you will end up with #Deleted in all your bound fields.
so you would have to move to another record.

One idea is:
Code:
Me.RecordsetClone.MoveLast
Me.Bookmark = Me.RecordsetClone.Bookmark

Again hope this helps
 

Users who are viewing this thread

Top Bottom