Tracking Forums, Newsgroups, Maling Lists
Home Scripts Tutorials Tracker Forums
 
  HOME    TRACKER    Visual Basic




Adding Hidden Field To Combo Box.


Is it possible (I thought it was) to add a hidden field to a combo box, i.e I want to have Text in the combo box that the user sees etc..but when it selects something then I want to use internally in code the ID that is attached to the text since my Design of my database is:ID: Some numberName: Name of Itemso is this possible? if so how? i suspect i need something different from cboBox.AddItem since the Item is just a string text field (what i would use for name) any help on how to add this hidden field of ID's and retrieve them later would be greatly appreciated thanks!




View Complete Forum Thread with Replies

See Related Forum Messages: Follow the Links Below to View Complete Thread
Combo Box && Hidden Field
I am using a combo box that pulls its list (customer names) from an Access DB. I can populate the box no problem with these customer names however each customer name also has an associated customer number.

Do combo boxes have a 'hidden' field to which I can assign this customer number? I want to use this number to do queries further along in the program.

Example:

"Customer 1", 0012
"Customer 23", 0034
"Customer", 03
"Test", 67

Thanks,
Steve

Adding A Combo Box To One Of The Field Of A DBgrid
frnds
Let me know is thre any method to add a combo box to one of the field of a
dbgrid??
thanks for any help

How To Insert A Hidden Field?
Hi everyone,

How can i insert a hidden field in Word?

Thanks!


Regards,
Michel

Hidden Field In ListView
Can we add hidden field on ListView? If yes how?

Hidden Date Field
Hey all,

I am a php/sql programmer that got stuck with a MS Access job! I know the access side, but on the backend I want an eventhandler that OnEnter puts the current YEAR (yyyy) in the field.

I have no clue how to get VB to create a current year. In php it would be date('Y'); and would print 2002 in the hidden field.

I have the private sub made - just no code inside it.

any help, RTFM's appreciated

Chris

MS Access - Hidden Field!
Does anyone know how to programmatically access the field called Order By in an access table using either ADO or DAO?

You can get to this field if you load a DB into Access 97, Design a table, Right mouse click on the design window, Select properties... You will get a window that has the following columns:

Description
Validation Rule
Validation Text
Filter
Order By

I can get a hold of all of these fields except the Order By field by using the ADOX.Catalog object
ie: tblNew.Tables(8).Properties(1).Value would be the Validation Rule field....

Please help if you can...

Corey

Listview Hidden Field
Is there a way to make a column of a Listview invisible so I can use it like a hidden field? Or is there a better way?

Thanks.

Vb And Email Hidden To Field Question
any possibility of sending email through vb but without showing the To: section of the email?

{RESOLVED THX} ComboBox Hidden Field?
Hey, back again..

Ihave a question about getting an ID corresponding to a selection in a combo box, is there such a thing as a hidden field or something similar?

(Using ADO and access2000 DB)
The scenario is, i have 3 tables

table agents
a_id / Name

table city
c_id / City

table streets
s_id / Street / c_id / a_id

now my problem is that i need to insert, a value Street into the streets table,
using 2 ComboBoxes as selection for city and name..

here's what i have so far..
i'm pulling data into the 2 combo boxes like so:
Code:
Private Sub Form_Activate()
' Add city list into Combobox
Set cityRS = New ADODB.Recordset
'select city
cityRS.Open "SELECT * FROM city", oDatabase, adOpenStatic, adLockOptimistic
'add city to combo box
cmbCity.Clear
Do While Not cityRS.EOF
    cmbCity.AddItem cityRS("City")
    cityRS.MoveNext
Loop

' Add agent list into Combobox
Set agentRS = New ADODB.Recordset
'select agent
agentRS.Open "SELECT * FROM agents", oDatabase, adOpenStatic, adLockOptimistic
'add agent to combo box
cmbAgent.Clear
Do While Not agentRS.EOF
    cmbAgent.AddItem agentRS("Name")
    agentRS.MoveNext
Loop
'Close Record Sets
cityRS.Close
Set cityRS = Nothing
agentRS.Close
Set agentRS = Nothing
End Sub
the above is most likely not the most efficient way to do it .. but i'm just learning.. so do give me a break

now for the update i have something like this..
Code:
Private Sub cmdSave_Click()
'ADD NEW STREET RECFORD
Set strRS = New ADODB.Recordset
'SQL TO ADD NEW RECORD
sql = "INSERT INTO streets (Street, c_id, a_id) VALUES ('" & txtStreet.Text & "', '" & cmbCity.Text & "', '" & cmbAgent.Text & "')"
strRS.Open sql, oDatabase, adOpenStatic, adLockOptimistic

that works fine except it inserts the names not id's of the items selected in the ComboBoxes..
so it boils down to one thing.. how do i show the user a name, and get the code to process an id
so that for instance my cmbAgent (ComboBox) will display column Name..
but at the same time i'm able to grab the a_id associated with the name selected..

Hopefully i've explained this well enough for you guys to understand..
i've seen a post here about this but it's for vb.net,

thanks for your help



Edited by - allmambo on 2/5/2005 7:46:55 AM

Combo With Hidden Value?
how can I display a combo with:

RED
GREEN
BLUE

When you select green for example, I could then reference a hidden value of say "ERT123" (means nothing special just a reference in a database).

So select the following to pass the corresponding value.

GREEN = "ERT123"
RED = "ABC456"
BLUE = "CFD789"

Previously I have done this:

cboProperty.AddItem "" & mRS.Fields("Property")
cboProperty.ItemData(cboProperty.NewIndex) = mRS.Fields("Propertyid")

Where Propertyid always equalled a number between 0 and 10

Now I need to use a string which I cannot set as the index.

Any help greatly appreciated.

Thanks in advance.


VB6SP3

Hidden Combo Info
Hello.

I'm in the mire over my combo boxes. I've set them up to take two differnt sets of data from my database so that they can display and return relational information.

The problem is that the recordset displays the index number & I want the box to display the text information of the combo box.

Th code below shows that I've extracted both an index number (eg 1,2,3,4)& title details (eg Mr. Mrs. Ms. Miss) from the database & that they both reside in my combo box somewhere. If my recordset gives an index number, what must I do to get the combo box to display the list of textual information?



VB Code:
str3Query = "SELECT * FROM [FeeEarners]"    Set rec3FeeEarners = dba3Database.OpenRecordset(str3Query, dbOpenDynaset)        rec3FeeEarners.MoveFirst    Do Until rec3FeeEarners.EOF        cboAddRecordBorrowedBy.AddItem rec3FeeEarners("Fee Earner")        int1Index = cboAddRecordBorrowedBy.NewIndex        cboAddRecordBorrowedBy.ItemData(int1Index) = rec3FeeEarners("ID")        rec3FeeEarners.MoveNext    Loop

Adding Data To Hidden Column.
Here is the Problem.

I have a Sheet that has Password Protection turned on. I need to do the the Following.

1) Lookup a Code on 2nd sheet.
2) Add this Info to Cell AZ1. ( Column is Hidden. )
3) Save the XLS file.

Of the Steps above, I have got the first step done. I can see that Cell AZ1 gets the data.

Problem:
When I reopen the Workbook I don't see the Information.

Here is what I have done.

Code:
'strNewPath is the Workbook being modified.
Set wksReport = ThisWorkbook.Worksheets("Report")
Set wkbFromData = Workbooks.Open(strNewPath, , True)

If bFlag = True Then
Set wksFromData = wkbFromData.Worksheets("Data")
wkbFromData.Unprotect ("XXX")
wksFromData.Unprotect ("XXX")

strSource = Left$(Trim$(wksFromData.Range("D8").Value), 4)
strSource = FindSource(strSource)
' Had to do the 2 Steps below as direct Assignment would not work.
' wksFromData.Range("AZ1").Value = strSource
wksFromData.Columns("AZ").Select
Selection.EntireColumn.Hidden = False

wksFromData.Range("AZ1").Value = strSource
'MsgBox wksFromData.Range("AZ1").Value -- Had this to check if the value was being stored.
' Did this to check on the Temp XLS if the Data is getting stored.
'wksFromData.Columns("AZ").Select
'Selection.EntireColumn.Hidden = True


wksFromData.Range("AZ1").Select
'wksFromData.Protect ("XXX")
'wkbFromData.Save -- Does not work.
'Workaround
wkbFromData.SaveAs strNewPath & "datta_temp.xls"
wkbFromData.Close
Set wksFromData = Nothing
Set wkbFromData = Nothing
End If

The Workaround that seems to work is to save the sheet as a new name and the changes are saved.

Any help is greatly appreciated.

TIA
Datta.

How Do I Make A True Combo Box With Foreign Key In A Hidden Column?
Hi!

I've been wondering for a few days now. I tried to make data entry forms using the DataCombo control, but although I can set the ListField property to a field that I want to show instead of the entry stored in the database, the foreign key shows up in the form when the combo is idle (not in the dropped-down state). I came to VB from Access, so I am accustomed to using the multicolumn combo they have there.

Can anyone give me a few pointers?

Also, I am sure most of people who read this know of a good button control. I need a button control with source (I want to compile it together with another OCX I am making for personal use by including it into the project) that can display a picture and does not use a Timer control or anything like this. Gold Button by Nightwolf is one that I found, and although it does not have a Timer control, it still has a delay after I press the button, which prevent me from pushing the mouse button for a few milliseconds.

Thanks in advance for everything!!!

Stanislav

Code For Adding Numbers From A Combox And A Textbox To Another Hidden Location
I am new to vb so could someone show me the code for adding numbers from a combox and a textbox to another hidden location so that it can be retrieved later
Jaynsilentbob

Adding Two Field's Data Ino One Field
hello

The following SQL command adds two fields data into one field.

tbl1 structure:
_____________________________
field1 field2

a1 b1
a2 b2
a3 b3
a4 b4
____________________________

Select field1,field2 as fieldNew from tbl1;

the result is :

___________________________
fieldNew

a1b1
a2b2
a3b3
a4b4

__________________________


But I want to get:


_________________________

fieldNew

a1
a2
a3
a4
b1
b2
b3
b4


________________________



Please anyone help me to solve this problem.


Thank you all.

Bye...

Adding Two Field's Data Into One Field Using SQL.
Hello...

Can anyone tell me how can I Get two different field's data into one (newly named) Field using SQL?or VB?

Adding Combo Text To A Dropdown Combo
I have a 0-dropdown box called batchcombo that is populated from a field in a database. When the user opens the form the combobox field is blank unless the user clicks in it then the database records are shown. I want the word "all" to display at form load and stay like that being that it goes away after the database is populated. I would really like it if this can be done on a 2-drop down list(read only)if possible

code:

Private Sub Form_Load()

batchcombo.Text = "all"
With Adodc1
.Recordset.MoveFirst
While Not .Recordset.EOF
batchcombo.AddItem .Recordset!batch
.Recordset.MoveNext
Wend
End With
end sub

[XL97] Excluding Hidden Cells That Weren't Hidden By A Filter?
It has been brought to my attention that in Excel '97 (and possibly other versions as well), the SUBTOTAL function doesn't actually exclude all hidden rows from its calculation - it only excludes those rows that where hidden by a filter. Rows hidden manually or via VBA code (i.e., without using one of Excel's built-in filters) are included in the total as if they were visible.

However, I need those rows to be excluded. Could anyone point me in the direction of a formula that would be able to do this? I've already accomplished it with a user-defined function, but some of the worksheets where I need this functionality are quite long and have a great many columns that need to be totaled/averaged/what-have-you, and the computers I have to work with aren't the fastest - they tend to choke on iterating through all the affected cells one at a time.

- David Prokopetz.

Adding A Field On The Fly
Is there a way to add a field to a database table through code in ADO?
thanks very much, ted

Adding A Field
I am trying to add a field to a DB, with SQL. Is this possible? Where should I look?

Adding A New Field.
Alright,
well I am making a database system for some people, and ive completed a good chunk of it.

now i just reliazed i needed to add another field in the database base.

Say i have Name, ID,Email. i need to add "address"/
now I use SQL statements to work with my database as i find that the easier, and i know ill have to rewrite all the my sql statements.

but for the future, how can i prevent this? as in if a new field is added then the sql statements are already updated.


especially for the insert statement.

Adding A Hyperlink To A Field Using VBA
Hi everyone. I'm trying to link to a file with a hyperlink. It's the only way I can think to do this. we currently get faxes sent to our desktop. I need to be able to double click my attachment field, pick my file, have it asign a unique name to the file, move it to my attachment folder, and then insert a hyperlink in the text box. I've managed to do everything except get the hyperlink to work. It puts the full path to my new file in the text box, but it doesn't do anything when I click on it. It looks like a hyperlink, but doens't act like one. Here is the code I have so far:


Code:
Private Sub Attachment_DblClick(Cancel As Integer)

Dim fs As Object
Dim dlgOpen As FileDialog
Dim vrtSelectedItem As Variant
Dim myDir As String
Dim OldName, NewName
Dim myString As String
Dim SourceFile, DestinationFile
Dim strFileName As String

myString = Format(Now(), "yyyymmddhms")

Set dlgOpen = Application.FileDialog(msoFileDialogFilePicker)
Set fs = CreateObject("Scripting.FileSystemObject")

With dlgOpen
.AllowMultiSelect = False
.Show

For Each vrtSelectedItem In .SelectedItems
myDir = vrtSelectedItem
Next vrtSelectedItem

End With

strFileName = Right(myDir, Len(myDir) - InStrRev(myDir, "", -1))

myEnd = Right(myDir, 4)

fs.CopyFile myDir, CurrentProject.Path & "Attachments"

OldName = CurrentProject.Path & "Attachments" & strFileName: NewName = CurrentProject.Path & "Attachments" & myString & myEnd

Name OldName As NewName

Me.Attachment.Value = NewName

End Sub
I've set the field type to Hyperlink. Can anyone tell me either a better way to link to a document, or how to use the value in the cell as a hyperlink?

Thanks for any help!

Dave

P.S. Forgot to mention, I'm using Access 2002 (XP)

Adding A Field To My Table
i am using this to make a table and fields in my database

Set db = OpenDatabase("C:WINDOWSSYSTEMDailyacivity.mdb")
Set tb = New TableDef
Set f = New Field
f.Name = "Date"
f.Type = dbDate
f.Name = "Shift"
f.Type = dbText
tb.Name = intpress
tb.Fields.Append f
db.TableDefs.Append tb

it makes the table but only one of the fields the shift field how can i add more fields?

Adding A New Field To A Table
Is it possible to add a new field to an existing table throught a SQL statement?
I've searched the forum but I did not find anything, can anyone help me?

Adding Field With ADOX
I'm trying to add a field to a table using ADOX. Adding the field is easy but I can't figure out how to set its default value. What should I add to the following code?

Dim oCat As ADOX.Catalog
Dim oTable As ADOX.Table
Dim oColumn As ADOX.Column

Set oCat = New ADOX.Catalog

oCat.ActiveConnection = _
"Provider=Microsoft.Jet.OLEDB.4.0;" & _
"Data Source= MyDatabase.mdb;"
Set oTable = oCat.Tables("MyTable")
Set oColumn = New ADOX.Column
With oColumn
.Name = "NewField"
.Type = adUnsignedTinyInt
End With

oTable.Columns.Append oColumn

Set oColumn = Nothing
Set oTable = Nothing
Set oCat = Nothing

Thanks!

Adding Field To Db Programmatically
I need to be able to programatically add a field of type text with a length of 70 to a database in ADO. If I can do this through code it will save me a very long and unnecessary trip.

thanks, Ted

Adding A New 'field' To The Database
I can't seem to figure out a easy way to add a field to a database.. This is what I'm trying.

Private Sub AddDetailDBFields(sFileName As String)
Dim adoRS_DetailFields As ADODB.Recordset

'Assume Connection Open to adoConn_SQLDB_Local

'Open Recordset
Set adoRS_DetailFields = New ADODB.Recordset
adoRS_DetailFields.Open "Detail", adoConn_SQLDB_Local

adoRS_DetailFields.Fields.Append "New Field Name", adDouble

adoRS_DetailFields.Close
End Sub

All I'm trying to do is add a new Field to a Database Table.
Thanks for the help.

Adding New Field In To Access
Hi All

We have a VB program which was written originally in VB5 and then we upgraded to VB6. Our original database was designed a few years ago in Access version 2. It only contains 5 fields. We use a data control to link to our Access file.

My question is:

Through our program is it possible to extend this to 6 fields by using a command code to insert another field which can also be incorporated in the program being already used?

The reason I ask this is that among the people that use the program, some have Access on and some do not.

Any help would be appreciated.

Thanks

Steve

Problem Adding DAO Field
i'm trying to append new field on existing database table but my code not working here's my current code using DAO:


Code:
Sub AddField()
Dim tblObjectTracking As TableDef
Dim AddField As Field
Dim X As Integer
Dim Fld As Field
On Error Resume Next
Set db = OpenDatabase("logfile.mdb", False, False, ";pwd=pass")
Set tblObjectTracking = db.TableDefs("log")
Set Fld = tblObjectTracking.CreateField("OT", dbText, 250)
With Fld
.AllowZeroLength = True
End With
With tblObjectTracking.Fields
.Append Fld
.Refresh
End With
With tblObjectTracking.Fields
.Append Fld
.Refresh
End With
db.TableDefs.Append tblObjectTracking
db.Close: Set db = Nothing
Set tblObjectTracking = Nothing
End Sub
anyone can help... thanksss
Edit by Moderator:
Posting a thread in a discussion forum is a pretty good indication that you require help, so no need to put that in your thread title.

Adding Data To A New Field
Hi,

I have used the following code to add a new field to a database. Is there a way to stop this field having a Null value but still keep it empty?


Code:


strSQL = "SELECT * FROM cells ORDER BY cell, Proof;"
Set db = OpenDatabase(lblDatabase.Caption, False, False)


Set tbl = db.TableDefs("cells")

' Create and append new Field objects
tbl.Fields.Append tbl.CreateField("Extra", dbText, 20)

Adding Together One Field In All Records.
In my database their is one field that has the revenue for one item how would i add together each of them to get a total revenue?

I also want to be able to delete one field in different records e.g. delete the revenue for each item how would i go about doing that?

Thanks for your help

Adding New Field To Table Through SQL
I have been asked to write a piece of SQL to add a new field to an existing table (SQL Server).

I haven't got a clue how to do it!

Can anyone help me?

Adding 2 Field Primary Key Using DAO
One last question...I want to define 2 fields as the primary key in a Jet database using DAO. I understand how to create an index on a single field using createindex but I am having problems setting 2 fields as a primary key. Any help would be greatly appreciated. Thanks in advance!!

More Than 1 Field On A Dropdown Combo Box
I am trying to display 2 fields in a combo box so that the client can select the correct item. Takes me 2 seconds to do that in VBA (MS Access) but I haven't been able to figure out how to do that in VB. Any suggestions? Please be specific since Access is my specialty as opposed to VB.
Thanks!

Help With Combo Boxes And A Field.
I'm trying to insert a feild into a combo box for my database program. I've used this bit of code.

With adoStock.Recordset
Do Until .EOF
If !englishname <> "" Then
cboName.AddItem !englishname
End If
.MoveNext
Loop
.Close
End With


However the program crashes. Giving me the error

Run Time error '91':
Object Veriable or With block veriable not set.

it highlights this line:
Do Until .EOF

Can anyone tell me what I've done wrong

Combo Field Database
Hi Guy's I have A probleme in opening my ado database in combobox
i have a database named Fournisseur.mdb that contain fileds
Nom,compagnie,pays..........
i have a cobobox named combo1
---------------------------------------------
I want the code that can allow me to call just "nom" filed in the combo1
that means i want to show "Nom" in the combo1?????
---------------------------
this is my info :
------------
Private Sub Form_Load()
Adodc1.ConnectionString = "Provider=Microsoft.Jet.OLEDB.4.0;" & "Data_& Source=" & SystemDir & "Fournisseur.mdb"
Adodc1.CursorType = adOpenDynamic
Adodc1.CommandType = adCmdTable
Adodc1.RecordSource = "Fournisseur"
Adodc1.Refresh
Set Me.DataGrid1.DataSource = Me.Adodc1
end sub
----------------------------------------------

i put this code but it's doesn't work That is it:
------------------------------------------------
private sub command1_click()
Do While Not adodc1.EOF
cboCombo.AddItem Adodc1.recordset.Fields ("nom")
Adodc1.recordset.MoveNext
Loop
cboCombo.Text = cboCombo.List(0)
end sub
------------------------------------------------
Please help Me !!!!!!!!!!!!!!!!!!!!
Milen regard's

Input A Field From A Db Into A Combo Box
I want to input the data from a db into a combo box. I am not sure how to do it.

Any suggestions?

ps, I am just learning

Thank you

Brian

Adding Field To Table On Import
How can I add a field to a table as I loop through and import a months worth of Excel Info. The field will contain the date (120103) using a string to identify the data.
the code is below. the command15_click() works fine. Its the addfield2() code where I get an error message. RunTIme error "3421" Data type conversion. any ideas would be helpful
for example: I need the first field to be:
120103 data...data..data
120203 data..data...data

Right now I only have data.

Code:
Private Sub command15_click()
Dim strname As String
Dim stryear As String
Dim itimer As String
Dim filestr As String
itimer = 31
strname = "I:Socc
eportsDailyLog_"
stryear = Combo23
filestr = Combo18 & Combo23
Call CLEAR_LOAD

Do While (itimer > 0)
strpath = strname & Me.Combo18 & Format$(itimer, "00") & stryear
DoCmd.TransferSpreadsheet acImport, 8, filestr, strpath, False, "C55:AA55"

Call addfield2

itimer = itimer - 1
Loop
MsgBox "FINISHED"

Sub addfield2()
filestr = Combo18 & Combo23
Set dbs = CurrentDb
Set tdf = dbs.TableDefs!(filestr)
' Create new field in table.
Set fld = tdf.CreateField(filestr, Number, 11)
fld.OrdinalPosition = 1
With TDef
.Fields.Append .CreateField("TextField9", dbText)
.Fields.Append .CreateField("IntegerField10", dbInteger)

End With
Set dbs = Nothing
End Sub

Adding One Or More Lines In A Memo Field
is there a fuction I can use to add lines in a memo field using VBA??

Adding A Field To An Access Table
Greetings,
On a particular user action, I would like to add a new field to an Access table. Is there a dynamic way to do so. ( kinda like when we are creating a table at Design time...)
Thanx

Adding A Field To The Begining Of A Recordset
Is there anyway of adding a field to the beginning of a ADODB recordset which is already populated? I would rather not changed the stored procedure which creates the recordset or have to create a new stored procedure. I don't think rs.Fields.Append can do this, can it?

Cheers

G

Getting Field Names And Adding To Lstbox
I am using the following code to try and get the name of the columns in my access database and am having no luck. Basically I want to add the names of all the columns to a listbox in the order they appear in the database:


Code:
Set ElementConn = New ADODB.Connection
Set ElementRecSet = New ADODB.Recordset

ElementConn.CursorLocation = adUseClient
ElementConn.ConnectionString = "Driver={Microsoft Access Driver (*.mdb)};Dbq=" & App.Path & "Periodic Table.mdb;"
ElementConn.Open

Set ElementRecSet = ElementConn.Execute("SELECT * FROM Table2 ORDER BY AtomicNumber")

Dim i As Long

For i = 1 To ElementRecSet.Fields.Count
lstline1.AddItem ElementRecSet.Fields(i).Name
lstline2.AddItem ElementRecSet.Fields.Item(i).Name
lstline3.AddItem ElementRecSet.Fields.Item(i).Name
Next i

ElementConn.Close
I get an error at the red line (Runtime error 3265) "Item could not be found in the collection corresponding to the requested name or ordinal"

Any ideas?

Thanx

Adding Field To Index (on-the-fly) In Access Using DAO
So, I'm trying to change / "upgrade" the structure of an access database using (for reasons that are too long to go into now) DAO

I've stored all the "relevant" info in a custom file structure, and I'm then comparing that with the structure of the DB.

Adding New tables, fields, indexes works fine...

But when I try to add a newly created field to the Primary Index using something like this

Code:
Set td = db.Tabledefs(TableName)
Set id = td.indexes(IndexName)
id.Fields.Append td.Fields(FieldName)
I get Error 3367 - Can't append. An object with that name already exists in the collection.
But it doesn't / can't already exist because I only just created the field.. I've checked the Fields collection of the index and the field I'm trying to add definitely isn't there.

So I tried it a different way....
First Delete the index...
Then Recreate the entire index..
This gives me exactly the same error when I try to add the first field (which is not the new field) to the index... but at that point the id.fields.count = 0, I just created the index object, so it's empty....

So I'm guessing that the error is occuring for a reason other than the VB Help "stated" reason.... does anyone have any idea what else could cause this error?

Adding Nullable Field To Recordset?
hi all,

i have a recordset that I create in code. trouble is one of my fields needs to be able to be blank, but i get a

"canoot set non nullable field to null" error.

here's my recordset creating code:

sfsRS.ActiveConnection = Nothing

With sfsRS.Fields
.Append "Item_No", adBigInt
.Append "Description", adBSTR
.Append "Seq", adInteger
.Append "Cases Per Hour", adInteger
.Append "Qty", adDouble
.Append "Load (Hours)", adDouble
.Append "SHIP_DATE", adBSTR
.Append "SHIP_TIME", adBSTR
.Append "Comments", adBSTR
End With

the field i need to have allowed nulls is "Seq".

Adding Field Names To A Table
I have the following code which adds fields to a table. The problem is that some of the fields will end up having spaces in the names. This creates a problem because then vb assumes that the second word in the name is actually the variable type definition.
How do i get around this?

myConnect.Execute "ALTER TABLE Mark_Test ADD COLUMN " & SelMag(l) & " text;"

Adding A Calculated Field To A Datagrid...
Hi,

i asked this quastion once and no one answered me...
I have a function Age() on my module, it gets a date and calculates the age of this person with this date of birth...
I have a players table and when i put it in a datagrid i want to add another column which will use the players' date of birth and calculate this persons age, using the function on my module...

how can i do it?

please help... thanks a lot.

Adding Data To Database Field
Hi there,

I'm not sure at all how to do this so assistance will be much appreciated! I need to add a quantity amount (txtQuantity) to the field "Quantity" in my "CurrentStock" database. But it has to add to the value that is already in that field. Also if the txtProduct is "Laptop" then this amount needs to be added to the record 'Laptop' quantity. (i hope this makes sense!?) Heres my attempted code:


VBCODE Code:
Private Sub cmdUpdate_Click()
'When button is clicked, it will check input from check box and msgbox then update'
If Check1.Value = vbChecked Then
    OrderMsgBox = MsgBox("Please confirm that this order has been completed", vbExclamation + vbYesNo)
'If box is ticked and yes is clicked it will update the "completed" field'
If (Check1.Value = vbChecked) And (OrderMsgBox = vbYes) Then
    UpdateCompleted
    Unload Me
    UpdateStock1.Show
End If
End If
End Sub

Private Function UpdateCompleted()
'With condition to edit and update the completed field in the order table'
With datOrder.Recordset
.Edit
        .Fields("Completed") = Check1.Value
       
.Update

[color="Red"]If txtProduct.Text = "Laptop" Then
Add txtQuantity.Text[/color] (stuck here!)

End Function

Adding Database Field Attributes
From VB I have loaded up a .mdb file
I was just wondering how can I edit the field attributes

e.g.
The Description attribute
the Validation rule
default value etc..

Also, is there a good place to look to show how I can import values from an excel spreadsheet into my VB program!

Thanks

Adding Text To Listview Field?
Hi all.

I have a program that has about 7 text fields and I have one listview. I have an add button for adding a new contact, like an address book program, that will add all text fields respectively to the listview fields. Instead of using a database this time I'm using a dat file to store the listview saved information from the textfields. So far I have this:

Code:
'I know this doesn't look right
Private Sub cmdAddNew_Click()
Dim xItem As ListView
Dim intList As Integer

lstContacts.ListItems.Clear

For intList = 1 To lstContacts.ListItems(intList).ListSubItems
  If lstContacts.ListItems(intList).ListSubItems > 0 Then
    With lstContacts.ListItems(intList).ListSubItems
    .Add intList, , txtID.Text
    .Add intList, , txtFirstName.Text
    End With
  End If
Next intList

End Sub
------------------------------------------------------------------------------
Private Sub cmdListAll_Click()
Dim xItem As ListItem

lstContacts.ListItems.Clear

Open App.Path & "Contacts.dat" For Binary As #1
Get #1, , cUser
Close #1

With cUser 'cUser is in a module as a public type
  txtID = .Contact_ID
  txtFirstName = .Contact_FirstName
  txtLastName = .Contact_LastName
  txtAge = .Contact_Age
  txtEmail = .Contact_Email
  txtPhoneNumber = .Contact_Telephone
  txtAddress = .Contact_Address
  txtLocation = .Contact_Location
  txtComments = .Contact_Comments
End With

Set xItem = lstContacts.ListItems.Add(, "ID", txtID, , 1)
xItem.SubItems(1) = txtFirstName
xItem.SubItems(2) = txtLastName
xItem.SubItems(3) = txtAge
xItem.SubItems(4) = txtEmail
xItem.SubItems(5) = txtPhoneNumber
xItem.SubItems(6) = txtAddress
xItem.SubItems(7) = txtLocation
xItem.SubItems(8) = txtComments

End Sub


I did get somethiing back from it but it looked like the "ID" text, not the ID number in the id section, and in another case 0's in the text fields that hold strings, lol. At least my machine is still running.

If anyone would know how close or far off I may be that would be great. Thanks for all your time.

RJ

Copyright © 2005-08 www.BigResource.com, All rights reserved