Get The Current Procedure Name, Current Form Name . . .
I want to get the name of the:
- current project
- current form
- current module
- current function
- current procedure or method.
where I am working
How can I do to get it?
thanks and regards
View Complete Forum Thread with Replies
See Related Forum Messages: Follow the Links Below to View Complete Thread
Get Current Procedure Name
I need to write a logging class for some commercial software. I would prefer to write a dll with a Log() method. Then at the top each Sub() inside my exe I would put a single call like Call Log.LogCurrentPosition WITHOUT having to copy and paste each procedure name in!
Can anyone help me:
With vb 6 project, How can i retrieve the name of the current procedure called?
Getting Name Of Current Procedure
Is there a way of getting the name of the procedure that is currently being executed? Its for my error trapping routine:
Private Sub myProcedure()
On Error GoTo ErrorHandler
Msgbox "An unhandled error occurred." & vbCrLf _
& "Description: " & Err.Description & vbCrLf _
& "Module: " & Me.Name & vbCrLf _
& "Procedure: " & [color=DarkRed][name of procedure][/color]
So firstly, is there a way of getting [name of procedure] or do I have to manually write the name of the procedure as a string, like this...
& "Procedure: myProcedure"
...which is a bit tedious when I have loads of procedures!
Secondly, is this a satisfactory way to handle unhandled errors? I'm planning to put this code in every procedure, to handle any error that I haven't anticipated. Is it ok to use 'End' in this circumstance?
Thanks a lot!
Current Form, Current Sub
I want to right a generic error handler for my app. When an error occurs, a msgboc popups with the error number, error message. I would like the message to contain the current form or module that caused the errors and the current sub/function would be sweet also.
Me.Name work for forms, but not for modules.
no idea how to fetch the current sub.
Get Current Procedure's Module Name
i use VB6 and while on try to create a global errorhandler class, i was wondering if there is a way to get the name of the module the prodecure is(private or public; form or standard) to print to my log file. The public procedures are not the problem (since unique names) but e.g. text1_click might be in 2 or more private modules (forms).
Get Current Function/procedure Name
I'm creating a general error handler, and it would be very very usefull if I could make it show the name of the function where the error was detected.
The Err object provides a code and description, but isn't there anything where I could get the name of the function it's in at that moment?
I searched this forum and googled for various things, but nothing gets me in the right direction.
Thanks in advance.
Is there a way to determine what the name of the current procedure/function is at run time?
I want to be able to show a messagebox (or other things) saying "This is Sub GetFormProperties".
Current Function Or Procedure ...
Is there a way in VB to identify the name of the Procedure/Function which is being executed in the application ??
For instance ... If there is a function called TestFunc and when TestFunc is called I'd like to know the name of this function (Testfunc) inside this function (when control comes to this function). I do not want to hardcode this thing. Is there a system value that can provide me this information.
Current Procedure Name And Event?
hello all of you gurus:
does anyone know how to determine the current procedure and event that is
(in both a regular module and/or a class module)? Thanks.
Current Procedure / Method Name
I'm setting up an error log and would like to be able to get the current method/procedure name to send to my error logging routine. Any thoughts?
Current Position On Current Line *resolved- Code I Used Inside*
this is for VBA but i dont think it will matter if you know a way to do this in VB6 that would be great i will try to convert it from there on my own thanks
ok my question is that i have a textbox on a worksheet in excel and i want to be able to find out what the current position on the current line that im on. here is what im trying to do. ok i am first off converting a file from a emacs file to beable to be read and looked at in windows. and the tab stops to look right in windows. in emacs it make the tabs 8 spaces long and for some reason they are only like 5-6 or so in the textbox. and i want to beable to take a chr(9) which is tab and replace it with space(8) but here is where the problem is.
when you are in the first space on a line it and hit tab in emacs it moves over 8. then of you are on the 2nd it moves over 7 and goes to the same spot as the last tab this happens all the way over to space 8 where it starts over. and i need to be able to detect want spot the chr(9) was found on so i know how many spaces to go over. well hopefully someone can help. i currently dont have any code writen really. all i have is the code the replaces all chr(9) with space(8) if you want i can post that so you can look at how i do stuff.
well thanks for your help and hope you read this soon thanks
Get Current Month On Current System Language?[SOLVED]
Hi.Is there a way to msgbox the current month but on system language?This : [vb]msgbox Format$(Date, "Long Date")[/vb] would msgbox date, date num. etc in your own language but I only want to msgbox the month.
So how can i do this?
Subscript Error When Called By Current Sub Procedure
When I call the function "SplitResult" from a subprocedure I get an error msg - subscript out of range - which I presume means it can't find elements in the array (??)
BUT, when I then call the function "SplitResult" from a command button seperately, it works!
Ive had a hunt around the forum and on the net, but can't find out why!
The first Sub procedure
Private Sub Winsock1_DataArrival(ByVal bytesTotal As Long)
Timer1.Enabled = False
Winsock1.GetData sBuffer 'Put data into the sBuffer variable
txtSource = txtSource & sBuffer 'Print out to text box
SplitResult 'Call Split Sub Pro
And this is what it calls
Private Sub SplitResult()
HoldingBuffer = txtSource.Text
'Split the result into two parts
SplitResults = split(HoldingBuffer, "])")
txtSource.Text = Right(HoldingBuffer, Len(sBuffer) - Len(SplitResults(0)))
'Redefine variable names of parts of code
extrainfo = SplitResults(0)
maincode = SplitResults(1)
maincode = Trim(maincode) 'Trim the main code of white space
'Add Lost characters
extrainfo = extrainfo & "])"
'Output the two results to various areas
txtSource.Text = SplitResults(1)
frmExtraInfo.txtExraInfo.Text = extrainfo
All variables are declared in Option Explicit
So like I said - when I call the second bit of code from a command button after disabling it being called from the first, it works, but I need it to run without user intervention!
There's obviously something wrong with it, so if anyone can help me discover what, and find a solution, I'd be grateful. thanks
Current Drive Instead Of Current Directory
Hey again everyone !
Simple on this time....
I need the current drive of the running app. I can get the currnet directory by the following:
dim curdir as string
but...can I want just the drive letter.... can I do this without string manipulation ??
thanks again !
Is there any code that will allow me to use the objects on the current form when my code is in a module???
I have a listbox and i would like to be able to put my code for filling the listbox within a module
how can I do that without getting an "object required" error message???
Is Current Form On Top ?
How can i know if the current form is maximixed & on top or another applivation is on top(ex the iexplorer) ?
Can some one Please help
Forms: Need Select/Where OR Filter So Form 2 Opens With Form 1 Current Record
Should be easy... and will be when I get an answer...
Visual Basic forms app. I have two forms (frm_Offenders and frm_Vehicles). frm_Offenders works great (add, edit, delete records). frm_Offenders uses tbl_Offenders Access DB. frm_Offenders has a button to open frm_Vehicles. frm_Vehicles works great (add, edit, delete). frm_Vehicles uses tbl_Vehicles Access DB.
Problem is this... when I press button from frm_Offenders I need frm_Vehicles to open only showing records where CARDS_ID is equal. CARDS_ID is an autofill numeric field in tbl_Offenders (prime key). tbl_Vehicles also has a CARDS_ID field that is not autofill but is a prime key. When frm_Vehicles is open and you press the "Add" button a new record is created in tbl_Vehicles and the CARDS_ID field is autopop with the current record CARDS_ID from frm_Offenders.
So... both tables have CARDS_ID field. I need frm_Vehicles to open to the current record selected in frm_Offenders. Also no DataGrid view. Both forms have listboxes that when record is selected all other fields (name, address, etc.) are bound.
Currently frm_Vehicles opens with all records. tbl_Vehicles data would look something like this:
CARDS_ID v_Year v_Make v_Model
34 2000 Ford F-150
34 2007 Niss Pathfinder
35 2005 Dodg RAM 1500
36 1990 Chev Camero
tbl_Offenders data would look something like this:
CARDS_ID Name_Last Name_First Name_Mid
34 Smith John James
35 Doe Billy Bob
36 Sharp Albert Oscar
In short everything works great except being able to filter records on frm_Vehicles. Think I need a "Where frm_Offenders.CARDS_ID = frm_Vehicles.CARDS_ID" type of statement.
Edited by - wbwalsh on 9/2/2007 1:58:07 PM
Help Getting Current Time On Form
i need the current time on the my form in Text1. Can anyone help please, i am totally new to VB6, i am pretty good with VBA (Excel). But i cant seem to get the specifiers correct. Please help, and any extra info will be appreciated, such as the mail diffrences and such. thank you again.
Help Getting Current Time On Form
by the way... how can i use the format command to display me the time as: 21.07 instead of 9.07 pm (note that i want my display without seconds)
Use Current Record In A New Form
Is there a way to select a record with one form then open another form with the selected record from the previous form set as the current record in the second form.
The problem is when opening a second form the current record is always set to the first record in the table.
VB6 Current Active Form
I have got an issue where I need to find out at any given time which form is active. I have about 6 forms in my project. Basically below is my logic:
I only want to show a certain form only when a given form is visible. I have already tried to use:
If Screen.ActiveForm.Name = "form1"
but at certain times I get run time error 91 object variable or with block variable not set. I have tracked it down to the fact that Screen object doesnt exist sometimes which may be when other normal XP windows are open.
Ps I have already had a look at:
All in all what I am really trying to do is avoid 401 modal form errors!
Way To Find Out Current Form
Is there a way to find out the current form which is running. As i have a module which refers to a component (called Map in this case) on a form. So i have to do:
MainForm.Map.Height = 10
but what happens if I run the public sub in the module from a different form with the same Map componet do I have to rewrite a Sub and change the form name or can I some how get it to find out which form called the Sub and thus which map on which form needs its height setting to 10?
Module - Using Current Form
I've got a VB6 project that was working fine. I've taking a snippet of code which was copied into three different forms and was working fine. In the form, I was running a piece of code which was using "Me.TEXTBOXNAME.TEXT".
Well, I've realized that having the code in three places (and realizing I had to make a change to each), I've moved the code to a module instead. I've made it a public function, and my only problem now is that the Me.TEXTBOXNAME.TEXT syntax doesn't work. My project doesn't really seem to know how to read this data.
I need the module to pull the info. from the textbox named TEXTBOXNAME on whichever form is currently open (focus?)...
Does anyone know how I'd achieve this.
I know I could take a CHEAP out and put IF statements into the module, and hard-code the three form names, but I think there's an easier way. Any Ideas?
Background Around Current Form
hi im looking for a way to have a current form with a grey tint added to the windows background when the form is active , like when the shutdown button is pressed on XP. i would like to use this to produce my login screen module
Current Row And Current Cell
Best wishes for the year 2002 from belgium.
How to get the current row and current cell within
a datagrid when the user double click on a row or cell?
Status Of Current Record In A Form
I have a form in access which i use to add new records or edit them. It has a save button which I have an insert sql statement being executed (it works fine)into another table.
I want to know what is the status of the record before I execute my insert statement. I need to know if the record is a new record or if it is a record that has been edited/changed in order to execute my insert statement. My code looks like this:
if Me.recordset.editmode = adeditadd then
'execute my insert
' continue saving record
this doesn't work!!!
I aslo tried:
if me.recordset.recordstatus = dbrecordnew then
this doesn't work either!!!!
How To Pass Current Form As Parameter
My aim to have a common function to clear up all the fields/controls of the form. Now the code for this is common irrespective of what controls are present on the form. So I want to move it to a common module and then have each form call this. But for this i have to pass the current userform as a parameter to the common function. I tried passing ME as a parameter but that does not work.. Any ideas ?
Thanks in advance
Closing The Current Form, Opening A Different One
like the title says i'd like to 'close the current form, and open up a different one'.
for instance, the user can select something from the menu which will replace a form[s] which is open already.
any idea how i can do this?
Determine Current Form In MDI App (RESOLVED)
I want to determine which is the current (active) child form in an MDI application. Then I would like to update a status bar pane with the name of the form. The hard part is first one. How can I go about?
thx, in advance
How Can Display Current Time On A VB Form?
Hello there, I'm new in VB and I simply need to know how to display current time on a form(which I later turn into an exe file)
I have gotten this function below from this site which I believe works ... now I dont know how to go about using it so that the form or later(exe file) displays current time ... Actually I want this current time to be displayed on an exe application.
Function RetDateTime() As String
Appdate = Date
Apptime = Time
nl = Chr$(10) + Chr$(13)
RetDateTime = "Current Time : " & Apptime & nl & "Todays Date : " & Appdate
Question About Current Focus On A Form
is there a way to return the current object that has the focus? for example when the user hits F1, it says what the current control/object they are in is?
Capture Current Form As An Image In VB6
This must be really easy to do(!) but I just cant get it to work!!
I want to grab the current active visible form (a regular VB form I've created), controls and all, as an image so I can shove it in a picture box an another form.
I've found lots of code for grabbing the entire desktop, but I dont want it all and I'm getting tangled in knots trying to select only my form's part of the desktop. So I figure there must be a way to grab only the current form?
I've tried using "StretchBlt" but cant get the parameters right!
Any help would be really appreciated!!!
How To 'select Text' On Current Form
I'm looking to write one subroutine at the form level that will 'Select Text' on each Textbox as I tab through the form.
I don't necessarily want to add a sub to each textbox on the form.
Is this possible? Any ideas or suggestions?
How To Delete Current Record In Bounded Form?
Hi guys. I made bounded maintenance form customer table in my access db.
But when I try to delete a record by clicking on the delete button I get
the following error. I be happy if some one help me delete record successfully. Thanks
Run-time error '91'
Object variable or with block variable not set
pic ===>delete error
Option Compare Database
Private Sub cmdSearch_Click()
[t]Dim strStudentRef As String
[t]Dim strSearch As String
'Check txtSearch for Null value or Nill Entry first.
[t]If IsNull(Me![txtSearch]) Or (Me![txtSearch]) = "" Then
[t][t]MsgBox "Please enter a value!", vbOKOnly, "Invalid Search Criterion!"
'Performs the search using value entered into txtSearch
'and evaluates this against values in customerno
[t]strStudentRef = customerno.Text
[t]strSearch = txtSearch.Text
'If matching record found sets focus in customerno and shows msgbox
'and clears search control
[t]If strStudentRef = strSearch Then
[t][t]MsgBox "Match Found For: " & strSearch, , "Congratulations!"
[t][t]txtSearch = ""
[t]'If value not found sets focus back to txtSearch and shows msgbox
[t][t][t]MsgBox "Match Not Found For: " & strSearch & " - Please Try Again.", _
[t][t][t], "Invalid Search Criterion!"
Private Sub Command14_Click()
'''On Error GoTo Err_CmdAdd_Click
[t]'''Me.DataEntry = True
[t]'''Me.CmdFilter.Visible = False
[t]'''Me.CmdShowAll.Visible = True
'''DoCmd.GoToRecord , , acNewRec
If DCount("*", "Customer") = 0 Then
[t][t]Me.customerno = 1
[t][t]Me.customerno = DMax("Customerno", "Customer") + 1
[t][t]Me.customerName.Value = " "
Private Sub cmdDelete_Click()
Dim x As Variant
x = MsgBox(" You are abut to delete " & Me.customerName & " from this table - proceed ? ", vbOKCancel)
If x = 1 Then
Forms(0) How To Find Out What Index The Current Form Is
I need to find out what the forms index is for the current form I'm working on.
I've found a dodgy way of doing it, is there a better way?
My current way
me.tag = "whatever"
For I = 0 To Forms.Count - 1
If Forms(I).Tag = "whatever" Then
msgbox "this is form index " & I
There must be a better way?
Passing Current Form Parameter (Solved)
In my program i have many screens and i want to make sure the user can set a value to big or small for the width and height for each form. so instead of typing this code out each time i planned to pass the name of a current form to a module and then work out the resizing there.
Private Sub Form_Resize()
Dim sCurrentScreen As String '<---think its this thats wrong
'set the Current viewed screen as CurrentScreen
sCurrentScreen = Me.Name
the code above passes sCurrentScreen to the module below
Public Sub ScreenResize(sCurrentScreen As String)
Debug.Print "Current Screen = "; sCurrentScreen
'If the screen isnt maximised or minimissed
If sCurrentScreen.WindowState = 0 Then
'set the minimum screen width to 10500 twips
If sCurrentScreen.Width < 10500 Then sCurrentScreen.Width = 10500
'set the minimun screen height to 8000 twips
If sCurrentScreen.Height < 8000 Then sCurrentScreen.Height = 8000
'set the maximum screen to 10 twips less than the screen size
If sCurrentScreen.Height > Screen.Height Then sCurrentScreen.Height = (sCurrentScreen.Height - 500)
'set the maximum screen to 10 twips less than the screen size
If sCurrentScreen.Width > Screen.Width Then sCurrentScreen.Width = (sCurrentScreen.Width - 80)
this however doesnt work as it wont let me use sCurrentScreen.WindowState for example i think this is because im passing the value as a string instead of what i shoudl be passing it as? coudl anyone help with this please
thx in advance
Sending Current Record From One Access Form To Another.
Hope you all are doing well. I have created two access forms. I am able to pass the server filter to the second form but I need that I will also open the second form, such that – current ID of the first form will be also shown in the second form.
Any kind of help will be appreciated.
Thanks & Regards,
Unload Current Form And Load FrmMainMenu
Here is the scenerio. I have 2 forms, FrmMainMenu and FrmOrderEntry. From FrmMainMenu, I select FrmOrderEntry. In FrmOrderEntry FORM_LOAD, I unload the FrmMainMenu. Upon completion of data entry, click on either the the CLOSE BUTTON or the CONTROLBOX "X' rectangle, I want to unload FrmOrderEntry and reload FrmMainMenu. I have no joy getting it to work. Could some please point me to the right direction. Thanks
Here are the sample scripts I am using.
Private Sub Form_Load()
Private Sub BtnClose_Click()
FrmMainMenu.show vbmodal '
Private Sub Form_Unload()
How To Determine What Form Called Current Form.
I have to think this would be fairly simple but I wasn't able to find it in the archives.
Is there an API call or some type of property that can tell me what form called/displayed the current form?
Form1 ------>Form3---------> Form4
Form2------->Form3---------> Form4 ---------> Form5
If I'm in Form4, how can I tell that it was called/displayed via Form1 to Form3 to Form4 as opposed to Form2 to Form3 to Form4?
I'm using "Form3.Show vbModal" in Form1 to show the Form3.
I'm using "Form4.Show vbModal" in Form3 to show the Form4.
While in Form4, I'd like to know what forms were accessed to get there. I don't want to keep track of the forms using global variables because the forms may drill down to any number of levels. (Form5, 6, etc)
How To Find Out Which Form Displayed The Current Form
I have a form which can be called from multiple places throughout my application. However the form is to behave differently depending upon where it was called from.
The form is to always be shown modally, so how can I find out at runtime which form has invoked this form?