Microsoft Access Help
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
 
 
User Name:
Password:
Remember me
Iron Speed
Go Back   ASP Free ForumsDatabaseMicrosoft Access Help

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread ASP Free Forums Sponsor:
Ajax Application Generator Generate database and reporting .NET Web apps in minutes. Quickly create visually stunning, feature-rich apps that are easy to customize and ready to deploy. Download Now!
  #1  
Old May 7th, 2008, 04:16 AM
valoukh valoukh is offline
Registered User
ASP Free Newbie (0 - 499 posts)
 
Join Date: Jan 2008
Posts: 22 valoukh User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 6 h 10 m 22 sec
Reputation Power: 0
Forms - "Combo.Value"

Hi everyone. I'm building a vehicle bookings database and am currently trying to use some VB code to control the data.

I have a Bookings form, a Vehicles table and a Bookings table. I want to enter information into the Bookings form and have it write to the Bookings table. I'm using some VB code I found to allow users to add new vehicles, i.e. when someone types a vehicle name which isn't in the Vehicles table, it adds it to the Vehicles table, then inserts the full booking into the Bookings table.

This is the code:

Code:
 Private Sub ComboVehicle_NotInList(NewData As String, Response As Integer)

  'Allow user to save non-list items.

  Dim cnn As New ADODB.Connection

  Dim strSQL As String

  Dim bytUpdate As Byte

  On Error GoTo ErrHandler

  Set cnn = CurrentProject.Connection

  bytUpdate = MsgBox("Do you want to add " & ComboVehicle.Value & _
  " as a new vehicle?", vbYesNo, "Vehicle not found")

  If bytUpdate = vbYes Then

    strSQL = "INSERT INTO Vehicles(Vehiclename) " & "VALUES ('" & NewData & "')"

    Debug.Print strSQL

    cnn.Execute strSQL

    Response = acDataErrAdded

  ElseIf bytUpdate = vbNo Then

    Response = acDataErrContinue

    Me!ComboVehicle.Undo

  End If

  Exit Sub

ErrHandler:

  MsgBox Err.Number & ": " & Err.Description, vbOKOnly, "Error"

End Sub


The problem I'm having is with this line:

Code:
bytUpdate = MsgBox("Do you want to add " & ComboVehicle.Value & _
  " as a new vehicle?", vbYesNo, "Vehicle not found")


It seems "ComboVehicle.Value" is supposed to pull the current contents of the ComboVehicle dropdown box, but it doesn't seem to update. E.g. if you drop the box down and select "merc" but then decide to delete "merc" and type a new vehicle "atego" then press enter, the box pops up and says "Vehicle not found. Do you want to add merc as a new vehicle?". It would, however, add atego to the database, it's just displaying the old value.

Does anyone know if there's any way around this? I sort of understand what it's doing but I don't want my users to be confused!

Thanks,
valoukh.

Reply With Quote
  #2  
Old May 7th, 2008, 04:48 AM
AOG123's Avatar
AOG123 AOG123 is offline
Registered Hero
ASP Free Novice (500 - 999 posts)
 
Join Date: Oct 2006
Posts: 866 AOG123 User rank is General (90000 - 100000 Reputation Level)AOG123 User rank is General (90000 - 100000 Reputation Level)AOG123 User rank is General (90000 - 100000 Reputation Level)AOG123 User rank is General (90000 - 100000 Reputation Level)AOG123 User rank is General (90000 - 100000 Reputation Level)AOG123 User rank is General (90000 - 100000 Reputation Level)AOG123 User rank is General (90000 - 100000 Reputation Level)AOG123 User rank is General (90000 - 100000 Reputation Level)AOG123 User rank is General (90000 - 100000 Reputation Level)AOG123 User rank is General (90000 - 100000 Reputation Level)AOG123 User rank is General (90000 - 100000 Reputation Level)AOG123 User rank is General (90000 - 100000 Reputation Level)AOG123 User rank is General (90000 - 100000 Reputation Level)AOG123 User rank is General (90000 - 100000 Reputation Level)AOG123 User rank is General (90000 - 100000 Reputation Level)AOG123 User rank is General (90000 - 100000 Reputation Level) 
Time spent in forums: 3 Weeks 1 Day 20 h 52 m 33 sec
Reputation Power: 946
Hi,. you need to remember that the value you are adding to the combo doesn't exist until after it is added,.. so .value is no good,...

anyway,.


Code:
  bytUpdate = MsgBox("Do you want to add " & ComboVehicle.text  & _
  " as a new vehicle?", vbYesNo, "Vehicle not found")


Change to ComboVehicle.text as seen above,

thanks

AOG
Comments on this post
don94403 agrees: Good catch. I wouldn't have thought of that, myself!

Reply With Quote
  #3  
Old May 7th, 2008, 05:19 AM
valoukh valoukh is offline
Registered User
ASP Free Newbie (0 - 499 posts)
 
Join Date: Jan 2008
Posts: 22 valoukh User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 6 h 10 m 22 sec
Reputation Power: 0
Perfect! thank you

Reply With Quote
Reply

Viewing: ASP Free ForumsDatabaseMicrosoft Access Help > Forms - "Combo.Value"


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump

 Free IT White Papers!
 
Accelerating Trading Partner Performance
One in five. That's how many partner transactions have at least one error. That is an amazing statistic, particularly given the extraordinary leaps in innovation across the global supply chain during the past two decades. Download this white paper to learn more.

 
Competing on Analytics
This Tech Analysis is designed to help identify characteristics shared by analytics competitors, and includes information about 32 organizations that have made a commitment to quantitative, fact-based analysis.

 
Cost Effective Scaling with Virtualization and Coyote Point Systems
An overview of the industry trend toward virtualization, how server consolidation has increased the importance of application uptime and the steps being taken to integrate load balancing technology with virtualized servers.

 
Five Checkpoints to Implementing IP Telephony
Implementation planning for IP PBX software and IP telephony has become vital as businesses replace discontinued legacy PBX phone systems. This informative whitepaper outlines five "checkpoints" for any implementation plan that will help make IP communications a successful proposition.

 
Hosted Email Security: Staying Ahead of New Threats
In the last two years, email has become a fierce battleground between the nefarious forces of spam and malware, and the heroes of messaging protection. The spam volumes increased alarmingly every month, bringing clever new forms of phishing and virus propagation attacks.

 

Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 





© 2003-2008 by Developer Shed. All rights reserved. DS Cluster 2 hosted by Hostway