Topics Search

Sending string variable to table from form (vba)

Sending string variable to table from form (vba)
Views: 44
I'm trying to create a form that is used to enter purchase orders into an Access 2003 database.
Traditionally I would set them up using the wizard, and use the basic objects from the toolbar corresponding to the fields in my table.

But I wanted to update the way a field is entered. I have a combo box that has 3 choices for a prefix (25,45,95), then the user types in a text box to enter a 8 digit number.When the user leaves the text field, the prefix and the number entered into the text box are combined using a global string variable.

The trouble I'm having is coding the 'add record' button to transfer the variable into my table.

The pseudo code would be:
[Add button clicked event.

(string variable), and All other fields in form to corresponding fields in table-(string variable) to specific field in table]
Sponsored Links:

More topics

 

Sending string variable to table from form (vba)

Preview
I'm trying to create a form that is used to enter purchase orders into an Access 2003 database.

Traditionally I would set them up using the wizard, and use the basic objects from the toolbar corresponding to the fields in my table.

But I wanted to update the way a field is entered. I have a combo box that has 3 choices for a prefix (25,45,95), then the user types in a text box to enter a 8 digit number.

When the user leaves the text field, the prefix and the number entered into the text box are combined using a global string variable.

The trouble I'm having is coding the 'add record' button to transfer the variable into my table.

[Add button clicked event.
(string variable), and All other fields in form to corresponding fields in table-(string variable) to specific field in table]
 

Pass String variable from Popup form to Main form in vba

Preview
I need an urgent response to this issue.

My Ms Access application has 2 forms viz:
a) The Main form
b) A popup form

The Main form calls the popup form via a button click. The popup form has a combo box whose value is stored in a global string variable.

I want to reference this string variable from the Main form (with the popup form still running i.e popup.visible = false
 

access vba string concatenation with variable within a loop

Preview
I wrote a vba subroutine to concatenate a string with the loop incremental variable to form a new variable. However, it seems like it translate it as a string rather than the variable. I tried to find the solution and found one similar issue one user had asked, but I can not find the answer.

The following is the post.

Const Value1 as long = 5
Const Value2 as long = 12
Const Value3 as long = 7

For I = 1 to 3
MsgBox Value & I '<-- How to do this properly?
Next I

I want MsgBox to display 5 then 12 then 7 rather than Value1 then Value2 then Value3
I can't figgure out how to get Value and I to combine properly to do this
 

What variable type to use with memo field in VBA

Preview
on VBA Access 2003/07,
I have a VBA class module that loads a single record from 1 of 4 tables (via a main form and datasheet subforms) to another form.
Most of the fields are keys however 1 field is memo data type.

What data type is best to use for the variable / property procedure in the class module. String seems to work but are there any limits in string length in vba, or a better way of achieving this. I seem to remember reading somewhere that memo datatype fields the data is not stored in the access db only a reference, is there any way of using this and passing the reference to the text box

Also the data is passed to the form via an ADO recordset am I right in saying that there is no issue with string length in ADO recordsets
 

Strings

Preview
The string is the most regularly used values of an application. We have seen in the past that a string variable could be declared using the String data type. After declaring a String variable, it is initialized as empty. You can also initialize it with any string of your choice.
 

Filting query results within VBA code module

Preview
I use Access 2010 but haven’t written much VBA code and could use some help. I have a table that provides the name of a query in a text field. The field name is “Query”.

I have a field in this same table that shows a department value for each record. That fieldname is “Dept”.

Within a huge VBA function module I’m writing, I have a string variable assigned to the Query field called strQuery. I also have string variable assigned to the Dept field called strDept.

The query that is assigned to the variable strQuery is designed to return ALL results for ALL departments. However, I want the VBA to run the query and return results for only the department that are assigned to the variable strDept.

If I leave out the department limitation, it works fine with the following code:
 

"create table" issue

Preview
First post on the forum! On to the question. I am trying to get a table created in VBA that gets its table name from a form entry thats stored in another table, passed into a variable, and used as my table name. im getting a syntax error message box when running this section and cant figure out what ive done wrong.

Relevant code follows but first some things ive already tried. saved the whole thing as a string variable and used docmd.runsql. ive used quotes around field name and datatype. im stuck on this one
 

Pass a list of parameters to a sql string variable

Preview
I have a form with a command button which runs a sql query in a string variable. The sql string basically counts the number of branches with less than 2000 customers from a table with Branch Id and customerTotal columns.

However I want to run this query maybe 10 times with different fixed parameters. I.e. wherecustomers is :
 

SELECT in VBA Access (small db)

Preview
I want to invoke a small SQL statement to select datums from a table and pass that onto a string variable. Note I don't mean to dump the entire table into VBA but just 1x1 field, one at a time of course.

I have trouble finding how to use SELECT statements within VBA in a simple context as mine surley is. The fact is, the table contains the names of every checkbox in a form, I want VBA to get those names from the table, see if they = TRUE, and then APPEND to a new table (which, thankfully docmd.runSQL works for). It just seems much cleaner than having to pour in sixty control names into the VBA code.

I've heard about using querydefs but they seem way outside the scope of my application, which is small
 

Embedded/nested? Variable

Preview
Is there some sort of internal variable or table that can be used to store temporary variables? While running code you can obviously store data in variable, the variable are dumped.

So I want to store some variable at some place in the vba or access that I can afterwards collect that variable again when I rerun my code.

Only way I know is to add it into a table, but is there some other, easier way?