Repetitive Code

S

Senad

Hi All,

I have a lot of repetitive code I would like to fix somehow.

I have tried to go to Modules and put it there, and then call it with Call
RepetitiveCode but that does not work. Can someonve help. Thanks

Senad
 
L

Lynn Trapp

Is "RepetitiveCode" a Function or Procedure in your module? You didn't give
the Module the same name as the Function or Procedure, did you?
 
S

Senad

Well, stupid me.

Now you mentioned it, I did gave them both same names.

As soon as Irenamed it it worked perfect.

Now the error message I was receiving makes sence.

Thanks for the Hint.
Senad
 
S

Senad

I would not make it without your hint.

thanks

I have another question, and I would appreciate if you could help me out.

I am thinking about restructuring my database, and making an bound form
unbound form.

the from contains following fields:
combobox: Country
combobox: Agency
textfield: Date
memofield: Details
8 checkboxex

so I assume the code would start something like:
dim rs as recordset
dim db as database
rs=db.mydatabase

now how do I tell the command button to populate table with the information
I have entered above.

thanks

Senad
 
L

Lynn Trapp

What you do depends on what you want to accomplish. If you simply want to
enter new records into your table, then you could use code similar to the
following (bear in mind, this is just a sample and is based on entering 2
values into a table. NOTE: It's important to get the number of quotation
marks accurate. Obviously, if you want to do updates to your table a
different process will have to be followed.

Private Sub cmdInsertRecord_Click()

Dim v_DeptName As String
Dim v_Manager As String
Dim v_SQL As String
v_DeptName = Me.txtDeptName
v_Manager = Me.txtManager
DoCmd.SetWarnings (False)
v_SQL = "Insert Into Departments(DeptName, Manager) Values ("""
v_SQL = v_SQL & v_DeptName & """"
v_SQL = v_SQL & ","
v_SQL = v_SQL & """" & v_Manager & """"
v_SQL = v_SQL & ");"
DoCmd.RunSQL (v_SQL)
DoCmd.SetWarnings (True)

End Sub
 

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