View Full Version : I cannot see my VBA code
junyor 06-02-2008, 05:03 AM People,
I have a huge problem!!!
Suddenly I cannot see my VBA code anymore... I'm clicking on Build button and choosing "Code builder", but nothing happens... the vba code doesn't appear... I think I've lost all my code...
Has it happened with everyone before????
Tks!!
KenHigg 06-02-2008, 05:07 AM Did you put your code in a form module or did you create custom code modules? Does the code editor come up?
junyor 06-02-2008, 05:12 AM Ken,
I didn't created any module, I tried in other machine but the problem is in the file... I don't know what heppened... I was just put a condition in a text box, error occured and I had to close the form, after opening it, I couldn't see the code anymore... very strange...
Rgds,
KenHigg 06-02-2008, 05:30 AM You said you could not see your VBA code. Code generally code goes in a module using the VBA editor. What do you mean when you say you put a condition in a text box?
boblarson 06-02-2008, 05:36 AM See if you can get to it this way:
http://www.btabdevelopment.com/main/QuickTutorials/Howtogettoaformscodewoutopeningtheform/tabid/111/Default.aspx
If not, then I suspect you may have a corrupted database file.
boblarson 06-02-2008, 05:37 AM Oops - sorry Ken - I forgot.
KenHigg 06-02-2008, 05:48 AM Why not just try to answer their question instead of pointing everybody to your website?
And why not just delete yor post, you delete mine whenever you want to?
junyor 06-02-2008, 05:59 AM Ken,
What I meant is that I was put a condition in a text box "if txt... = "" then..." and then after closing the form and open it again I couldn't see the code anymore. I was not using a module, I created subs in the form.
Bob,
As I said, I was not using module, I tried also to repair the database but... nothing...
Thanks.
KenHigg 06-02-2008, 06:02 AM junyor, I hate to bail on you, looks like bob has it under control... :)
junyor 06-02-2008, 06:29 AM junyor, I hate to bail on you, looks like bob has it under control... :)
No problem, I have an old backup, I think I've lost just 1 workday... Now I'll create backups every 5 minutes....rsrsrs
Tks!
DCrake 06-02-2008, 06:42 AM When you say you lost your code. I did asume you meant the code behind the control events. Did you not try to create some new code on a new control or edit the existing code on an existing control?
From what is sounds like to me is that you have lost the connection somehow.
A solution is to create a new module then click the find button and enter the name of a known control on a known form that you know has some code attached to it.
It should point you in the right direction.
CodeMaster::cool:
boblarson 06-02-2008, 06:59 AM Why not just try to answer their question instead of pointing everybody to your website?
In case it escaped your notice, when I do that it is directly to SCREENSHOTS which make it easier to explain since they can see what I would be trying to take several sentences, or paragraphs, to try to explain. That's why I created the website in the first place - to make it easier to answer many frequently asked questions and in a more visual way.
boblarson 06-02-2008, 07:01 AM As I said, I was not using module,
If you are using VBA CODE (which is what you initially said) then you ARE using a module (albeit a FORM module) and if you looked closely at the screenshots I provided, you would realize I was talking about FORM modules and not regular modules. It just uses a method of opening up a new module or an existing one to get at the FORM module code.
junyor 06-02-2008, 07:08 AM Hi DCrake,
When I create a new module, there is no code in there...I cannot see my form/code. If I open my form and select "Code" from menu view or "Build" button, nothing happens... the VBA screen isn't opened...
It never happened before!! I think there is an error with my database...
I'm already working on my old backup...
Thanks a lot!
boblarson 06-02-2008, 07:10 AM What version of Access are you working with? Just in case it is 2007, have you done this yet:
http://www.btabdevelopment.com/main/QuickTutorials/A2K7Howtoenablecodeandmacros/tabid/57/Default.aspx
junyor 06-02-2008, 07:20 AM What version of Access are you working with? Just in case it is 2007, have you done this yet:
http://www.btabdevelopment.com/main/QuickTutorials/A2K7Howtoenablecodeandmacros/tabid/57/Default.aspx
Hi bob,
I've checked and there is no form module in my DB. The office version is 2000
Rgds
KenHigg 06-02-2008, 07:22 AM In case it escaped your notice, when I do that it is directly to SCREENSHOTS which make it easier to explain since they can see what I would be trying to take several sentences, or paragraphs, to try to explain. That's why I created the website in the first place - to make it easier to answer many frequently asked questions and in a more visual way.
Yeah, I took a peek a while back. Nice work. Really didn't have time to scrutinize the content for accuracy, although I am aware of some of the authors work - :p
boblarson 06-02-2008, 07:23 AM Hi bob,
I've checked and there is no form module in my DB. The office version is 2000
Rgds
If you don't have any form modules and you don't have any standard modules then how were you entering VBA code and where?
KenHigg 06-02-2008, 07:25 AM If you are using VBA CODE (which is what you initially said) then you ARE using a module (albeit a FORM module) ...
I'm pretty sure you can have 'vba code' in an app and it NOT be in a module. :)
boblarson 06-02-2008, 07:27 AM I'm pretty sure you can have 'vba code' in an app and it NOT be in a module. :)
And how would that be Ken? Other than using some built in functions within a property, you would still have to use a form module, a standard module, or a class module to use VBA.
KenHigg 06-02-2008, 07:31 AM You can have an iif() or string functions, etc most anywhere - :)
boblarson 06-02-2008, 07:33 AM Those are not VBA code Ken - those are native functions.
KenHigg 06-02-2008, 07:47 AM If you put an iif() in a query then I think it's safe to say that you put a piece of vba code in the query since iif() is the vba library. The object browser doesn't show it in 'native' access anything as far as I can find - :)
boblarson 06-02-2008, 07:51 AM You're grasping at straw there Ken.
KenHigg 06-02-2008, 08:02 AM Not at all. The user said his code zonked and you said he couldn't have code where he said he had it. Looks like he tried to put an if statement in somewhere to control the user input (or something) and your answer sounded like he would have to do it in a module. I was simply replying that he could (maybe?) put a pc of code, say an iif() in somewhere other than a module to do what he wanted.
boblarson 06-02-2008, 08:09 AM Hi bob,
I've checked and there is no form module in my DB. The office version is 2000
Rgds
I would suggest posting the db here so we can put this to rest.
See here how to upload to the forum:
http://www.access-programmers.co.uk/forums/showthread.php?t=140587
KenHigg 06-02-2008, 08:12 AM Fat chance - we probably run him off by now :p ... Sorry, I'll shut up :)
junyor 06-02-2008, 08:37 AM Hi people,
As you can see in the attached file, there is no code but the form is still there and if you try to open the vba window from the form you cannot see it.
I had something like that inside the form: (it's a piece of the code)
Private Sub cmdsalvar_Click()
On Error GoTo Err_cmdsalvar_Click
If IsNull(Nome.Value) Then
MsgBox "O campo Nome obrigatório!", vbCritical
Nome.SetFocus
Exit Sub
End If
DoCmd.GoToRecord , , acNewRec
Exit_cmdsalvar_Click:
hide
MsgBox "Dados gravados com sucesso", vbInformation
DoCmd.Close , , acSaveNo
Exit Sub
Err_cmdsalvar_Click:
MsgBox Err.Description
Resume Exit_cmdsalvar_Click
End Sub
Private Sub cmd_Click()
If Not IsNull(DLookup("perfil", "user", "numero = " & Me.txtnumero)) Then
a = DLookup("perfil", "user", "numero = " & Me.txtnumero)
Numero.SetFocus
Numero.Text = Me.txtnumero
Else
On Error GoTo Err_cmd_Click
DoCmd.GoToRecord , , acNewRec
Exit_cmd_Click:
Exit Sub
Err_cmd_Click:
MsgBox Err.Description
Resume Exit_cmd_Click
End If
End Sub
Private Sub cmdverifica_Click()
If IsNull(txtverifica) Then
MsgBox "O número da conta não pode ser nulo", vbCritical
txtverifica.SetFocus
Exit Sub
ElseIf Len(txtverifica.Value) <> 20 Then
MsgBox "Conta inválida! a conta deve conter 20 dígitos!", vbCritical
txtverifica.SetFocus
Exit Sub
End If
Dim Nome As String
If Not IsNull(DLookup("nome", "contas", "conta = " & Str(Me.txtverifica))) Then
Nome = DLookup("nome", "contas", "conta = " & Me.txtverifica)
subform.Visible = True
disabled
lbl2.Caption = Nome
regra1
Else
DoCmd.GoToRecord , "Contas_Segmentation", acNewRec
On Error GoTo Err_cmdverifica_Click
show
Conta.SetFocus
'Criar uma function para isso
Conta.Text = txtverifica.Value
cmdsalvar.Visible = True
cmdcancelar.Visible = True
Funcionalidade.SetFocus
Conta.enabled = False
txtverifica.enabled = False
cmdverifica.enabled = False
Exit_cmdverifica_Click:
Exit Sub
Err_cmdverifica_Click:
MsgBox Err.Description
Resume Exit_cmdverifica_Click
Exit Sub
cmdverifica_Click:
MsgBox Err.Description
Exit Sub
End If
End Sub
Rgds,
KenHigg 06-02-2008, 08:40 AM Bob's right, you had all of that in a form module. I'll let him look at it :)
KenHigg 06-02-2008, 08:44 AM On second thought - (:p) As it looks like your code IS gone, I would simply open the form in design view, click on View->code and paste the entire chuck of code back into your module - ???
JBurlison 06-02-2008, 10:14 AM In case it escaped your notice, when I do that it is directly to SCREENSHOTS which make it easier to explain since they can see what I would be trying to take several sentences, or paragraphs, to try to explain. That's why I created the website in the first place - to make it easier to answer many frequently asked questions and in a more visual way.
Agreed this was my first thought also, dose the code work actively see if you can get it to error then debug it.
|
|